#!/usr/bin/perl
# por_palabra
# Octavio Martinez de la Vega
# Buscando por palabra clave en titulo u resumen.
# Presenta autores y folios de las presentaciones libres y da las ligas a esos archivos.


use CGI qw(:standard);
use DBI;

print "Content-Type: text/html\n\n";
print '<meta http-equiv=Content-Type content="text/html; charset=macintosh">';
print "\n<head>\n","<title>Por Palabra</title>\n","</head>\n","<body>\n";
print '<IMG SRC="GUIRNALDAREDBIO2010.gif" WIDTH=150 HEIGHT=150 ALIGN=RIGHT>',"\n";
print h2("REDBIO M&eacute;xico 2010<br>B&uacute;squeda por Palabra(s) Clave<hr>");

if (param()) { # Ya se tienen datos
$autor = param("autor");
$dbh = DBI->connect ("DBI:mysql:host=localhost;database=redbio","omartine", "password",
 {PrintError => 1, RaiseError => 1});
print h2("Clave: $autor");
print h3("Se presentan los trabajos en \"presentaciones libres\" que contienen la palabra o frase \'$autor\' en el t&iacute;tulo o resumen.<br>(puede ver el resumen del trabajo haciendo \'click\' con el rat&oacute;n en la liga del folio del trabajo)<hr>");
$orden = "select folio, tipo_a, titulo from trabajos where titulo like \'%$autor%\' or resumen like \'%$autor%\' and aceptado='1' order by folio;";
$sth = $dbh->prepare ($orden); $sth->execute ();
while ( @row = $sth->fetchrow_array ) {
           print "<a href=$row[0].html>$row[0]</a> ($row[1]) - $row[2]<hr>\n";
         }
# PENDIENTE
#print "<b>En trabajos corregidos:</b><hr><br>";
#$orden = "select folio from autorind_cor where autori like \'%$autor%\' order by autori;";
#$sth = $dbh->prepare ($orden); $sth->execute ();
#while ( @row = $sth->fetchrow_array ) {
#           print "$row[0]<a href=$row[1].html> Folio: $row[1]</a><hr>\n";
#         }

print "<a href=_indice.html>Regresar al Indice</a>";

} else {
 print start_form();
 print p("Puede introducir una palabra o frase para buscar en los trabajos libres<br>",
"Palabra o frase: ", textfield("autor"), "<br>");

 print p(submit("ENVIAR"), reset("BORRAR"));
 print end_form(), hr();
 print "<a href=_indice.html>Regresar al Indice</a>";

}
print end_html;
