|
A little more efficient to do
$row = mysql_fetch_assoc($result);
echo "Location: " . $row['location'];
mysql_fetch_array pulls the indices and the names.. assoc only pulls the field names.
You should also have some error checking (this goes before mysql_fetch_assoc()
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
and if you're expecting multiple rows of information (after the last code segment)
while ($row = mysql_fetch_assoc($result)) {
echo $row["location"];
echo '<br>';
}
and you don't have to close the connection - php will do it automatically.
|