Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: PHP
Expertise: Beginner
Aug 21, 2006

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);
Nathan Broslawsky
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap