Hi,
I have a problem and don't know how to resolve it. I connect to database and run a query. When I try to do a mysql_fetch_rows, it doesn't work. If I just get the number of rows returned and go through them it works fine.
$sql="Select * from tbProducts";
$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
$n = mysql_num_rows($result);
for ($i = 0; $i < $n; $i++) { // this works
printf("Name: %s<br>\n", mysql_result($result,$i,"ProdName"));
printf("Price: %s<br>\n", mysql_result($result,$i,"ProdPrice"));
}
while ($row = mysql_fetch_row($result) { // this doesn't work!
printf("Name: %s<br>\t", $row["ProdName"]);
printf("Price: %s<br>\n", $row["ProdPrice"]);
}
Thanks,