Simple Question - Limit by.. Start number #

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

Simple Question - Limit by.. Start number #

Post by Qaid »

Hi,

I have a code where I limit the MySQL database to a maximum of 5 post, then and ad is displayed, then i have the same code again, but how do i then start from post 6 to 10?

Thanks
Qaid
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

LIMIT {row to begin at}, {number of rows to fetch}

so....

"LIMIT 0, 5" then "LIMIT 5, 5"
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: Simple Question - Limit by.. Start number #

Post by aerodromoi »

Qaid wrote:Hi,

I have a code where I limit the MySQL database to a maximum of 5 post, then and ad is displayed, then i have the same code again, but how do i then start from post 6 to 10?

Thanks
Qaid
Just as a suggestion - why don't you read the database output into an array (mysql_fetch_array) and insert the ad while looping through the array (while printing out its contents)? This way you don't need two queries.
Post Reply