Okay, I got it to work in my first search script, but I'm not quite sure how to put it into my alphabetical search script. If I change anything, something else will stop working. Here's my script for the alphabetical search limiting records on a page:
<?php
// Connect to the database
$db = mysql_connect("localhost","xxxxx","xxxxxx");
mysql_select_db (members);
// Show 5 rows of data, starting from whatever position $start is equal to
if (!isset($start)) $start = 0;
$query = "SELECT * FROM m2m ORDER BY company LIMIT " . $start . ", 5";
$result = mysql_query($query);
// Now we print out the results, starting by making a table
echo ("<table border = '0' width = '80%' align='center'>");
echo "<font color=navy><u>MHHP Member Discounts</u></font><p>\n";
while ($rows = mysql_fetch_row($result))
{
printf("<tr><font color=navy>%s<br>%s<br>%s<br>%s<br>%s<br>%s<br>%s<p></font></tr>\n", $rows[2], $rows[3], $rows[4], $rows[5], $rows[6], $rows[7], $rows[8]);
}
// do another query to get the number of rows in our table
$query = "SELECT count(*) as count FROM m2m";
$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> ";
if($numrows > ($start + 5))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 5) .
"\">Next</a><BR>\n";
// Finally we close off the table
echo "</table>";
?>
I did this script different than the other search one because for some reason I couldn't do the limit records and put in next/previous links in the other script.