View Single Post
Old 02-26-2005, 08:37 AM   #5 (permalink)
hatchet
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,137
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
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.
hatchet is offline   Reply With Quote