Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-10-2012, 12:09 AM   PM User | #1
Vernk
Regular Coder

 
Join Date: Oct 2011
Posts: 113
Thanks: 9
Thanked 1 Time in 1 Post
Vernk is an unknown quantity at this point
WHILE lOOP limit help

PHP Code:
$cnt=0;
while(
$something mysql_fetch_array($querytrue && $cnt<100){
  
//process....
  
$cnt++;

Will this work , or something like this I am trying to achieve
Vernk is offline   Reply With Quote
Old 10-10-2012, 12:35 AM   PM User | #2
Wuteverx1972
New Coder

 
Join Date: Aug 2010
Posts: 53
Thanks: 6
Thanked 1 Time in 1 Post
Wuteverx1972 is an unknown quantity at this point
You can set the limit several ways.

One way is by setting a limit on your query:

PHP Code:
$querymysql_query("SELECT * FROM Persons LIMIT 0,100");

while(
$row mysql_fetch_array($query))
  {
  echo 
$row['FirstName'] . " " $row['LastName'];
  echo 
"<br />";


Another way is using the for method:

PHP Code:
for($i 0; ($condition) && $i 100$i++){ 
    
//process 

Your method should work fine as well but haven't tested it.
Wuteverx1972 is offline   Reply With Quote
Users who have thanked Wuteverx1972 for this post:
Vernk (10-10-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:47 PM.


Advertisement
Log in to turn off these ads.