<?
include ("connection.php");
print "<title>ANISEED CURATOR - Article Search</title><br>";

include ("frames_header.php");

$Ppmid=trim($_POST["pmid"]);
$Ptitle=trim($_POST["title"]);
$Ppaper=trim($_POST["paper"]);
$Pauthor=trim($_POST["author"]);

print "<center><h3>Article matching your query</h3></center>";


$requete="SELECT \"ARTICLE_ID\" from \"ARTICLE\"";



if (strlen($Ppmid)>0) $requete.="INTERSECT SELECT \"ARTICLE_ID\" from \"ARTICLE\" where \"PUBMED_ID\"='$Ppmid'";

if (strlen($Ptitle)>0) $requete.="INTERSECT SELECT \"ARTICLE_ID\" from \"ARTICLE\" where \"TITLE\" ilike '%$Ptitle%'";

if (strlen($Ppaper)>0) $requete.="INTERSECT SELECT \"ARTICLE_ID\" from \"ARTICLE\" where \"PAPER\" ilike '%$Ppaper%'";

if (strlen($Pauthor)>0) $requete.="INTERSECT SELECT \"ARTICLE_ID\" from \"ARTICLE\" where \"AUTHORS\" ilike '%$Pauthor%'";


$requete="SELECT * from \"ARTICLE\" where \"ARTICLE_ID\" in ($requete)";



$stmt=pg_query($c,$requete);

$NUM=pg_num_rows($stmt);

if ($NUM==0) print "<center><h3>No Article is matching your query ! </h3></center>";
else print "<center>$NUM results</center><br><br>";

while ($row=pg_fetch_array($stmt))
{

$id=$row["ARTICLE_ID"];
$pmid=$row["PUBMED_ID"];
$title=$row["TITLE"];
$authors=$row["AUTHORS"];
$paper=$row["PAPER"];


print "
<div style=\"border:1px solid black; background: white; color:black; padding:5px;margin:5px;\">

<center><b><font color=\"#D64242\">$authors</font></b><br>
<i>$title</i><br>
$paper<br>
<font size=\"-1\">Pubmed ID: <b>$pmid</b></font><br>
<font size=\"-1\">Aniseed Article ID: <b>$id</b></font><br>
<br>
</center>
<center>
<a target=\"_blank\" href=\"delete-article.php?id=$id\"><img border=\"0\" src=\"pictures/button-cur-delete.gif\"></a>
&nbsp;&nbsp;
<a href=\"edit-article.php?id=$id\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a>
</center>
</div>
<br><br>";




}






include ("frames_footer.php");
?>