Return to Snippet

Revision: 10550
at January 3, 2009 16:42 by iridium


Initial Code
function one_result($query) {
   $result = mysql_query($query);
   $row = mysql_fetch_row($result);
   return($row[0]);
}

Initial URL


Initial Description
Simple but useful function for getting a single piece of data from a database and placing it straight into a variable.

Example:
$variable = one_result("SELECT columnOne FROM table WHERE columnTwo=whatever");

This would insert the value of columnOne where columnTwo is 'whatever' into $variable

Initial Title
Single MySQL Result

Initial Tags
mysql

Initial Language
PHP