I have a doubt. Why can't we store the elements of mysql_fetch_row in an array and then use it later in the code?
For example, this bunch of code gives unexpected waiting time error.
$result=mysql_query($query) or die(mysql_error());
$n=mysql_num_rows($result);
$a=array();
$a[$i]=array();
for ($i=o; $i<$n; $i++)
{
$r=mysql_fetch_row($result);
$a[$i][0]=$r[0];
$a[$i][1]=$r[1];
}
echo $a[0][1];
echo $a[0][0];
Maybe you are looking for mysql_fetch_array
try to change this
$r=mysql_fetch_row($result);
to
$r=mysql_fetch_num($result);
Better way is to use mysql_fetch_assoc()
function.
$result = mysql_query($query) or die(mysql_error());
$a = array();
if ($result !== false) {
while ($row = mysql_fetch_assoc($result)) {
$a[] = $row;
}
}
var_dump($a);
And BTW in for
loop declaration you have o
instead of 0
!