I adapted this from another Forum post for my own database and it worked fine
On The First Page
but all the Next Pages provide blank tables when there should be lots of results.... the searchterm and searchtype and orderby criteria come from the form and the SQL query works fine, its just generating the subsquent results pages that isn't happening...
Is it something to do with needing to recapture the search criteria (from a search form page) each time, and if so what do I need to add?
Michael info@achuka.co.uk
<?php
// Connect to the database
$db = mysql_connect("localhost","username","");
mysql_select_db (nonfiction);
// Ask the database for the information from the table
// Show 5 rows of data, starting from whatever position $start is equal to
if (!isset($start)) $start = 0;
$query = "SELECT * FROM poetry WHERE ".$searchtype." like '%".$searchterm."%' order by ".$orderby." LIMIT " . $start . ", 5";
$result = mysql_query($query);
// Now we print out the results, starting by making a table
// The following HTML only for testing purposes...
//Print a table with the following column headings
echo '<table align="center" cellpadding="2" cellspacing="2" border="1">
<tr align="center">
<td align="center"><b>Title</b></td>
<td align="center"><b>Name</b></td>
<td align="center"><b>Month</b></td>
<td align="center"><b>Year</b></td>
<td align="center"><b>Publisher</b></td>
<td align="center"><b>Rating</b></td>
<td align="center"><b>Comment</b></td>
</tr>';
//Print each item.
$query_result=@($query);
while ($row=@mysql_fetch_array($query_result)) {
echo " <tr align=\"center\">
<td align=\"left\">$row[Title]</td>
<td align=\"left\">$row[Name]</td>
<td align=\"left\">$row[Month]</td>
<td align=\"left\">$row[Year]</td>
<td align=\"left\">$row[Publisher]</td>
<td align=\"left\">$row[Rating]</td>
<td align=\"left\">$row[Comment]</td>
</tr>";
}
// do another query to get the number of rows in our table
$query = "SELECT count(*) as count FROM nonfiction";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 5) .
"\">Previous</a><BR>\n";
if($numrows > ($start + 5))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 5) .
"\">Next</a><BR>\n";
// Finally we close off the table
echo "</table>";
?>
www.achuka.co.uk
ACHUKA Children's Books UK