$row["ID"] will give you the data you need from the array, but there is a bit more behind the scenes info you should know.
You could use the next line.
$row = mysql_result($result, 0, 0);
That will give you just the ID value into the $row variable as whatever type ID is. It should be noted that mysql_result is SLOWER then mysql_fetch_assoc, or mysql_fetch_row because it only grabs one piece of the mysql result instead of grabbing a whole row at a time.
mysql_result works with the entire result like a spread sheet. It also does not automatically increment the result to the next row like the mysql_fetch* commands do. In certain situations it is faster because you could grab any column from any row in the result set without parsing all the records. This is really kind of silly though because you would be better off chanigng your query to only return the rows you want instead of using mysql_result to pull out a single value.
In normal usage though, the mysql_fetch_assoc is almost as fast as mysql_fetch_row because the the result already has the field names. There is no extra query involved to get the field names. If your going to pull out the same data from each row, then the fetch routines are much faster.
$row = mysql_fetch_assoc($result)
$id = $row["ID"];
Main Topics
Browse All Topics





by: arantiusPosted on 2004-12-11 at 07:26:59ID: 12799880
$row["ID"]