note 84023 modified in control-structures.while by danbrown

From: Date: Fri, 14 Aug 2009 18:41:01 +0000
Subject: note 84023 modified in control-structures.while by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159484@lists.php.net to get a copy of this message
Due to the fact that php only interprets the necessary elements to get a result, I found it convenient to concatenate different sql queries into one statement: <?php $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 */ } } ?> [EDIT BY danbrown AT php DOT net: Contains a bugfix supplied by "Ira" on 14-AUG-09 to address an extra '(' in the leading if statement.] --was-- Due to the fact that php only interprets the necessary elements to get a result, I found it convenient to concatenate different sql queries into one statement: <?php $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 */ } } ?> http://php.net/manual/en/control-structures.while.php

« previous php.notes (#159484) next »