Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Advice


PHP Advice

Reply
  #1 (permalink)  
Old 09-17-04, 03:16 PM
andyX andyX is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP Advice

Can anybody help me out with a bit of PHP code that I’m trying to create ?
I want to write a script to pull from a DB a list of results based on a search heading, but only show the fist 20 then provide a link to show the next 20 from the DB then the following 20.
I can count the number of results with the heading that I want to use and pull the first 20, I just can’t find any info on how to pull the next 20 and so on with out repeating the first set of results.
The results from the DB will be updated all the time so giving them an auto increment value will not work either.

I would much appreciate any help, hopefully with a script in PHP that I can transform to do the job.
AndyX
Reply With Quote
  #2 (permalink)  
Old 09-17-04, 07:37 PM
hardcoded's Avatar
hardcoded hardcoded is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
SELECT myfields FROM mytables WHERE mysearch LIMIT start,20

However, I'm not 100% sure if the second argument is the end position of the result set ot the size of the result set (I haven't played with SQL for a couple of months now...), but look in the doc for "LIMIT", that's what you're looking for.
__________________
http://www.hardcoded.net
Reply With Quote
  #3 (permalink)  
Old 09-18-04, 04:48 AM
andyX andyX is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks Hardcoded

I will have a look at the Limit. I have seen that before in my admin.

Thanks AndyX
Reply With Quote
  #4 (permalink)  
Old 09-20-04, 01:50 PM
andyX andyX is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Am I right in thinking, that to get the next 20 I will have another my SQL code block like this !
SELECT myfields FROM mytables WHERE mysearch LIMIT start 20,20;

Is this last bit of code right ?

Reply With Quote
  #5 (permalink)  
Old 09-20-04, 02:38 PM
hardcoded's Avatar
hardcoded hardcoded is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
well, you have to remove the "start" keyword. This word is supposed to be replaced by your starting row.
__________________
http://www.hardcoded.net
Reply With Quote
  #6 (permalink)  
Old 09-20-04, 10:32 PM
Orbitz Orbitz is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by andyX
I can count the number of results with the heading that I want to use and pull the first 20, I just can’t find any info on how to pull the next 20 and so on with out repeating the first set of results.
The results from the DB will be updated all the time so giving them an auto increment value will not work either.
AndyX

You are on the right track.
Google search with this keywords: PHP pagination

You will find plenty of results on what you've been trying to accomplish.
See the sample on my website, the journal sections -

Last edited by Orbitz; 09-20-04 at 10:34 PM.
Reply With Quote
  #7 (permalink)  
Old 09-21-04, 02:33 PM
andyX andyX is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Hardcoded and Orbitz

I've got it now.
I'll give it a go !

Thanks again AndyX
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Mouseover with Single PHP page rjwebgraphix PHP 7 09-16-04 05:15 PM
php with Apache in windows eDevil PHP 3 08-08-04 12:03 AM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
PHP search engine-need some advice darkcarnival Website Reviews 18 08-06-03 06:35 PM


All times are GMT -5. The time now is 04:30 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.