February 13th, 2000, 01:20 AM
Hi, Thanx for reading.
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.
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
Phone 547) 587474
More info (link)
*Inside the link*
Income: 5 dlls
Display this for each result.
Thaaaaaaanx allot to all
February 13th, 2000, 07:55 AM
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");
// next determine if offset has been passed to script, if not use 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");
// now you can display the 20 results returned
print "Name: $data[name]<br>n";
print "Phone: $data[phone]<br>n";
print "<a href='detail.php3?id=$data[id]'>More info</a><p>n";
// 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
print "<a href='$PHP_SELF?offset=$newoffset>PREV</a> n";
// calculate number of pages needing links
// $pages now contains int of pages needed unless there is a remainder from division
// has remainder so add one page
for ($i=1;$i<=$pages;$i++) // loop thru
print "<a href='$PHP_SELF?offset=$newoffset'>$i</a> n";
// check to see if last page
// not last page so give NEXT link
print "<a href='$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...
[This message has been edited by rod k (edited February 13, 2000).]