I have a query which could return multiple rows.
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
$data[] = $row;
foreach ($data as $row){
echo $row['...'];
}
}
The problem is that it only prints one row, while i should have 2 rows printed.
Could someone help me out?
The problem is probably that you’re re-using the
$rowvariable. Also, the logic is a bit strange: why are you looping through$dataevery time you fetch a new row? Did you mean to do this instead: