How can I section a results display? lets say I have 15 results in the page, how can I make that only display 10 reults and automaticly make the respective links to the next 10 results and so on?? like altavista search.
Next page-> (2,3,4)
I know how to limit the result by adding the LIMIT 0, 3 example but I cant read all other results.
Thanx allot
And by the way... How can I make another page for details?? The page that Im making its a directory of companies so the first page display basic info like Company name, phone number. but I want to open a new page with more detailed info about the company like
Name:McRonald's
Phone http://www.devshed.com/Talk/Forums/frown.gif547) 587474
More info (link)
Thaaaaaaanx allot to all http://www.devshed.com/Talk/Forums/smile.gif
Luis,
I know from your other question you wanted to know the number of matches so you know how to do that. Of course, you'll have to do two queries - one without the limit and one with:
$numresults=mysql_query("select count(*) from table where YOUR CONDITIONAL HERE order by WHATEVER");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset))
{
$offset=0;
}
// get results (assuming a limit of 20, use whatever you need)
$results=mysql_query("select id,name,phone from table where YOUR CONDITIONAL HERE order by WHATEVER limit $offset,20");
// you'll need to write a script to get the detail from the table (where id=$id) and display it
// next we need to do the links to other results
if (!$offset) // bypass PREV link if offset is 0
{
$prevoffset=$offset-20;
print "<a href='https://forums.devshed.com/archive/index.php/$PHP_SELF?offset=$newoffset>PREV</a> n";
}
// calculate number of pages needing links
$pages=intval($numrows/20);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%20)
{
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) // loop thru
{
$newoffset=20*$i;
print "<a href='https://forums.devshed.com$PHP_SELF?offset=$newoffset'>$i</a> n";
}
// check to see if last page
if (!(($offset/20)==$pages))
{
// not last page so give NEXT link
$newoffset=$offset+20;
print "<a href='https://forums.devshed.com/archive/index.php/$PHP_SELF?offset=$newoffset'>NEXT</a><p>n";
}
That should do the trick for you. Of course, you'll probably want to clean up the HTML output...
Rod
[This message has been edited by rod k (edited February 13, 2000).]