mysql_query returns a resource you can use with these methods to fetch each row from the result:
The most common function used is mysql_fetch_assoc which fetches the row as an associative array using the column names as the key names:
<?php
$result = mysql_query(...);
while ($row = mysql_fetch_assoc($result)) {
print $row['columnName'];
}
mysql_free_result($result);
?>
I would recommend switching to the MySQLi extension instead. It supports more MySQL features and has procedural and object-oriented implementations. The PDO_MYSQL extension offers some improvements over MySQLi, but it only has an object-orientated implementation so it takes a little more to get up and running with.
solved Set database column values to a variable in PHP [closed]