Is there a quick and dirty way to get the value of one column from one row? Right now I use something like this:
$result = mysql_query("SELECT value FROM table WHERE row_id='1'");
$row = mysql_fetch_array($result);
return $row['value'];
It seems there must be able to consolidate the second and third lines.
These three lines seem like a lot just to get the value from one column from one row. I tried this:
$result = mysql_query("SELECT value FROM table WHERE row_id='1'");
return mysql_fetch_array($result)['value'];
But that doesn't work. I am just trying to find out if there is a simpler, more to the point, way of getting one value like this.
解决方案
use this:
$result = mysql_query("SELECT value FROM table WHERE row_id='1'");
return mysql_result($result, 0);