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 ta
Do u want this?
$output = array();
while($row = mysql_fetch_array($result)){
$output[] = $row['value'];
}
return $output;
use this hacker)
$result = mysql_result(mysql_query("SELECT value FROM table WHERE row_id='1'"), 0);
if you want it to return only one value use the limit keyword
/* Limits Results to 1 */
$result = mysql_query("SELECT value FROM table WHERE row_id='1' LIMIT 1;");
$row = mysqli_fetch_assoc($result)
echo $row['value'];
use this:
$result = mysql_query("SELECT value FROM table WHERE row_id='1'");
return mysql_result($result, 0);
You can use GROUP_CONCAT ( http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat ) function to make them into one field.
What you should look for is an encapsulation mecanism. For example you could create a classe User that would correspond to a rows of SQL table "user". Then you could get his id just with a single line:
$user->getID();
You could also create a class that would aggregate all the user and then use something like this:
$collection->getUserID("3435563");
But really there isn't a simpler way to do it in my knowledge.