Question About While Function


Subject: Question About While Function
Hi!

Can someone of you explain me the difference between this two functions and which should i use in standard?

Code: [Download] [Hide] [Select]
if ($row = $db->sql_fetchrow($result))
{
$i = 0;
do
{
// php funcs

$template->assign_block_vars('iprow', array());

$i++;
}
while ($row = $db->sql_fetchrow($result));
}


Code: [Download] [Hide] [Select]
while ($row = $db->sql_fetchrow($result))
{
// php funcs

$template->assign_block_vars('iprow', array());

$i++;
}


Thanks!

Subject: Re: Question About While Function
The do{}while(); execute one time at least.

Profile PM  
Subject: Re: Question About While Function
Thanks! Informpro

now i also found the function on php.net.... yesterday i cant find it 8)

http://www.php.net/manual/en/control-structures.do.while.php

Subject: Re: Question About While Function
It's not a function ...

Profile PM  
Subject: Re: Question About While Function
I would use the WHILE.

Anyway it's a matter of personal taste.

Subject: Re: Question About While Function
Yes, but you're right: while is better, we don't rewrite the $sql->fetch_rowset, DRY :p

Profile PM  
Subject: Re: Question About While Function
ok thank you guys :)


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.0986s (PHP: 17% SQL: 83%)
SQL queries: 11 - Debug Off - GZIP Enabled