Can someone please explain the most efficient method to return a value from within a while loop, for use before the while loop initiated.
Tried the following-
echo $var1;
while($row = mysql_fetch_array($query1)){
$var1 = $row[0];
}
Returns unset variable.
I also tried:
$var1= 1;
echo $var1;
while($row = mysql_fetch_array($query1)){
global $var1;
$var1 = $row[0];
}
Just echos 1.
This may sound strange, but is your echo before or after the while loop? In your above example, you show it to us as being before the loop – and we wouldn’t expect that to show much.