devxlogo

Retrieving a Single Value from a Database

Retrieving a Single Value from a Database

This PHP function pulls a single field from a single record in the database once the MySQL connection has already been established:

function getField($field, $tbl_name, $condition = 1){	$result = mysql_query("SELECT $field FROM $tbl_name WHERE $condition");	return @mysql_result($result, 0);}$myValue = getField("fieldName","myTable","id = " . $uniqueID);

devx-admin

Share the Post: