PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 13th, 2000, 02:20 AM
ltena ltena is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Mexico DF Mexico
Posts: 16 ltena User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ltena
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

Name:McRonald's
Phone 547) 587474
More info (link)

*Inside the link*

Name:McRonald's
Phone: 58445
Objetive:Fast Food
Income: 5 dlls

Display this for each result.

Thaaaaaaanx allot to all

Reply With Quote
  #2  
Old February 13th, 2000, 08:55 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
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");

// 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
{
$prevoffset=$offset-20;
print "<a href='$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='$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='$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).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > How?? diplay 5 on 5 results


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT