Hi,
I have been trying to display 10 records per page and then display links to next pages etc but I can't seem to get it to work.
Here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search Results - Environmental Publications Database</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h3>Search Results - Environmental Publications Database</h3>
<?php
$dbcnx = @mysql_connect('localhost', 'root', '');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!@mysql_select_db('ijdb')) {
exit('<p>Unable to locate the publication ' .
'database at this time.</p>');
}
// The basic SELECT statement
$select = 'SELECT DISTINCT id, pubname, pubdesc, pubdate, orgid, pages, pubno, cost';
$from = ' FROM pub';
$where = ' WHERE 1=1';
$aid = $_POST['aid'];
if ($aid != '') { // An author is selected
$where .= " AND authorid='$aid'";
}
$cid = $_POST['cid'];
if ($cid != '') { // A category is selected
$from .= ', pubcategory';
$where .= " AND id=pubid AND categoryid='$cid'";
}
$oid = $_POST['oid'];
if ($oid != '') { // An organisation is selected
$where .= " AND orgid='$oid' ";
}
$searchtext = $_POST['searchtext'];
if ($searchtext != '') { // Some search text was specified
$where .= " AND pubname LIKE '%$searchtext%' OR pubdesc LIKE '%$searchtext%'";
}
?>
<table width="600">
<tr>
<th width="90%">Publication Name</th>
<th width="10%"><div align="left">Date</div></th>
</tr>
<?php
$publications = @($select . $from . $where);
if (!$publications) {
echo '</table>';
exit('<p>Error retrieving publications from database!<br />'.
'Error: ' . mysql_error() . '</p>');
}
$pubname = ereg_replace('\[(B|EB|I|EI|L|L=|L=[-_./a-z0-9!&%#?+,\'=:;@~]+|EL|E)?(]|$)', '', $pubname);
while ($publication = mysql_fetch_array($publications)) {
echo "<tr valign='top'>\n";
$id = $publication['id'];
$pubname = htmlspecialchars($publication['pubname']);
$date = $publication['pubdate'];
echo "<td><a href=\"pub.php?id=$id\">$pubname</a></td>\n";
echo "<td>$date</td>\n";
}
?>
</table>
</body>
</html>
Any help would be greatly appreciated.