If I run a mysql query that gets a single field from a row in a database
table, what is the easiest way to get the value from the result?
I normally do something like this:
$query = "SELECT name FROM users WHERE id = 1"
$result = mysql_query($qu ery);
list($name) = mysql_fetch_row ($result);
Obviously this is one less line to write than
$row = mysql_fetch_row ($result);
$name = $row['name'];
Is there a simpler way than using the list function with a single
parameter?
Thanks
Hamilton
table, what is the easiest way to get the value from the result?
I normally do something like this:
$query = "SELECT name FROM users WHERE id = 1"
$result = mysql_query($qu ery);
list($name) = mysql_fetch_row ($result);
Obviously this is one less line to write than
$row = mysql_fetch_row ($result);
$name = $row['name'];
Is there a simpler way than using the list function with a single
parameter?
Thanks
Hamilton
Comment