Ec (2); do... while statements will always execute code blocks once, then check the conditions and repeat the loop, while the conditions are true. Syntax do & nbsp ;{& nbsp; codetobeexecuted; & nbsp ;}while (condition); for example, the following example defines a loop, starting with i1. Then it will add 1 more and write some output. Then, if the condition is checked, the loop will continue to run as long as I am less than or equal to 5: & l script ec (2); script
The do... while statement will always execute the code block once, then check the conditions and repeat the loop, and the conditions are true.
Syntax
Do
{
Code to be executed;
}
While (condition );
For example
The following example defines a loop starting with I = 1. Then it will add 1 more and write some output. Then, if the condition is check, the loop will continue to run as long as I am less than or equal to 5:
$ I = 1;
Do
{
$ I ++;
Echo "The number is". $ I ."
";
}
While ($ I <= 5 );
?>
/* Example 1 */
$ I = 1;
While ($ I <= 10 ){
Echo $ I ++;/* the printed value wocould be
$ I before the increment
(Post-increment )*/
}
/* Example 2 */
$ I = 1;
While ($ I <= 10 ):
Echo $ I;
$ I ++;
Endwhile;
?>
$ Q1 = 'some query on a set of tables ';
$ Q2 = 'similar query on a another set of tables ';
If ($ r1 = mysql_query ($ q1) & ($ r2 = mysql_query ($ q2 ))){
While ($ row = mysql_fetch_assoc ($ r1) | ($ row = mysql_fetch_assoc ($ r2 ))){
/* Do something with $ row coming from $ r1 and $ r2 */
}
}
?>
While ($ data = mysql_fetch_assoc ($ requeteID )){$ Menu. ='$ Menu. = ($ data ['id'] = $ _ GET ['id']? 'Selected> ':'> ');$ Menu. = $ data ['name'].'';}Echo $ menu;?>