1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Mexico DF Mexico
    Rep Power
    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.

    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

    Phone 547) 587474
    More info (link)

    *Inside the link*

    Phone: 58445
    Objetive:Fast Food
    Income: 5 dlls

    Display this for each result.

    Thaaaaaaanx allot to all
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Niagara Falls (On the wrong side of the gorge)
    Rep Power

    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
    if (empty($offset))
    // 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

    while ($data=mysql_fetch_array($result))
    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
    if ($numrows%20)
    // 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
    if (!(($offset/20)==$pages))
    // 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).]

Similar Threads

  1. Using sessions for search / results pages
    By Quirk in forum PHP Development
    Replies: 10
    Last Post: December 15th, 2003, 08:36 PM
  2. Limit results on 'left join' query
    By tippiedog in forum MySQL Help
    Replies: 1
    Last Post: November 12th, 2003, 07:58 AM
  3. Replies: 3
    Last Post: August 27th, 2003, 04:26 PM
  4. search results coming from multiple tables
    By frostfire in forum MySQL Help
    Replies: 0
    Last Post: August 12th, 2003, 09:23 AM
  5. Refining search results
    By Ides in forum ASP Programming
    Replies: 3
    Last Post: May 28th, 2003, 11:08 PM

IMN logo majestic logo threadwatch logo seochat tools logo