hey...
I have a search function which is used to search my PostgreSQL database. I have included the code below
<html>
<head>
<title>Search</title>
</head>
<div align="center">
<?php
include ('includes/header.html')
?>
<body>
<p>  </p>
<p>Enter a Author or Article title to begin searching</p>
<p>  </p>
<form name="form" action="search.php" method="post">
<input type="text" name="q" />
<input type="submit" name="Submit" value="Search" />
</form>
<p></p>
<p>  </p>
</body>
<?php
//include ('includes/footer.html')
?>
</div>
</html>
and...
<html>
<head>
<title>Search</title>
</head>
<?php
include ('includes/header.html');
?>
<div align="center">
<body>
<p> </p>
<?php
//connecting to the database
include('includes/db_connect.php')
?>
<?php
//$sql = "select * from jfs where author ilike '%$search_author%' order by issue";
//$sql = "select* from jfs where author like '%searchstring%' order by issue";
$sql = "select * from jfs where author ilike '%$search_author%'" ;
$result_set = pg_Exec ($conn, $sql);
$rows = pg_NumRows($result_set);
if ((!$result_set) || ($rows < 1)) {
echo "<H1>ERROR - no rows returned</H1><P>";
exit; //exit the script
}
for ($j=0; $j < $rows; $j++)
{
$issue = pg_result($result_set, $j, "issue");
$page = pg_result($result_set, $j, "page");
$author = pg_result($result_set, $j, "author");
$title = pg_result($result_set, $j, "title");
$format = pg_result($result_set, $j, "format");
$url = pg_result($result_set, $j, "url");
?>
<table table border="3" width=60%>
<tr><th>Issue</th><th>Page</th><th>Author</th><th>Title</th><th>Format</th><th>URL</th></tr>
<TR>
<TD width=10%>
<?php echo "<a href=$url> $issue </a>"; ?>
</TD>
<TD width=10%>
<?php echo "<a href=$url> $page </a>"; ?>
</TD>
<TD width=15%>
<?php echo "<a href=$url> $author </a>"; ?>
</TD>
<TD>
<?php echo "<a href=$url> $title </a>"; ?>
</TD>
<TD width=10%>
<?php echo "<a href=$url> $format </a>"; ?>
</TD>
<TD width=30%>
<?php echo "<a href=$url> $url </a>"; ?>
</TD>
</TR>
</table>
<?php
}
?>
<?php
pg_FreeResult($result_set);
pg_Close($conn);
?>
</TABLE>
</body>
</div>
<?php
//include ('includes\footer.html');
?>
</html>
this works in that i get a set of results when the user enters a search term and click search and do not get results when no term is entered but the problem is that no matter what term is entered into the search field the same results show up every time.
help?
el nino