Rather than:
Code:
while($row = mysql_fetch_array($result)){
printf("<b>Title:</b> %s<br> <b>Origin:</b> %s<br>", $row["title"],$row["origin"]);} ?>
Use:
Code:
$row = mysql_fetch_array($result);
printf("<b>Title:</b> %s<br> <b>Origin:</b> %s<br>", $row["title"],$row["origin"]);
?>
That's some pretty ugly code. Keeping it neat will save you headaches later on.
Both mysql_fetch_assoc() and mysql_fetch_row(), the former returning an associative array and the latter returning a numerical array, are pointless aliases, of which PHP has many. They're not technically deprecated in favour of mysql_fetch_array(), but they should be. mysql_fetch_array() can take a second argument: MYSQL_NUM to behave like mysql_fetch_row(), MYSQL_ASSOC to behave like mysql_fetch_assoc(), and MYSQL_BOTH to fetch an array with both numerical and associative indices, which is the default behaviour.
Bookmarks