use Column name in select statement as the variable name
<?php
mysql_connect("mysql153.secureserver.net","java2s","password");
mysql_select_db("java2s");
$query = "SELECT id, firstname FROM Employee";
$result = mysql_query($query);
while (list($id, $name) = mysql_fetch_row($result)) {
echo "$name ($id) <br />";
}
?>
Related examples in the same category