https://www.icyphoenix.com/viewtopic.php?f=17&t=6905
-----------------------------------
KugeLSichA
Wed 03 Feb, 2010 02:37

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 linenumbers=false]
	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]

[code linenumbers=false]
	while ($row = $db->sql_fetchrow($result))
	{
			// php funcs

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

			$i++;
	}
[/code]

Thanks!


-----------------------------------
Informpro
Wed 03 Feb, 2010 11:12

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


-----------------------------------
KugeLSichA
Wed 03 Feb, 2010 12:32

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


-----------------------------------
Informpro
Wed 03 Feb, 2010 15:26

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


-----------------------------------
Mighty Gorgon
Thu 04 Feb, 2010 00:49

Re: Question About While Function
-----------------------------------
I would use the WHILE.

Anyway it's a matter of personal taste.


-----------------------------------
Informpro
Thu 04 Feb, 2010 11:18

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


-----------------------------------
KugeLSichA
Fri 05 Feb, 2010 01:39

Re: Question About While Function
-----------------------------------
ok thank you guys :)


