Hi,
I'm using a pretty nifty script for paging database entries, yet I want to modify this to LIMIT the results alphabetically. Here is a script similar to what i'm using:
<?
mysql_connect("localhost","user","pass");
mysql_select_db("db");
if(!$rowstart) $rowstart=0;
$query = mysql_query("SELECT * FROM table1 LIMIT $rowstart,6");
$query2 = mysql_query("SELECT * FROM table1");
while ($get = mysql_fetch_array($query))
{
//display results
}
if ($rowstart>$numrows)
{
$back = $rowstart-6;
echo "<a href='browse.php?rowstart=".$back."'>< Previous <a>";
}
echo "|";
$numrows=mysql_num_rows($query2);
if($rowstart+6<$numrows)
{
$forward = $rowstart+6;
echo "<a href='browse.php?rowstart=".$forward."'> Next > </a>";
}
echo " ";
$count = 1;
$new = 0;
$pages = ($numrows/6) + 1;
for($count=1; $count<$pages; $count++ . $new+=6)
{
if($new == $rowstart)
{
echo " <a href='browse.php?rowstart=".$new.">".$count."</a> ";
}
else
{
echo " <a href='browse.php?rowstart=".$new."'>".$count."</a> ";
}
}
So this will list the results and limit them to 6 per page, with 1 2 3 4, etc below the results.
So, Is there a way of modifying the code to do this so the results are displayed, A B C D E etc. So when you click A it lists all the results starting with A, when you select B it lists all the results starting with B, etc. And will still also LIMIT them so there are only 6 results displayed on each page.
Thanks
Ant