PHPBuilder - Access Style DLookup function for MySQL



RSS Twitter
Snippets Databases

Access Style DLookup function for MySQL

by: Brian Levine
|
May 16, 2003

Version: 1.0

Type: Function

Category: Databases

License: GNU General Public License

Description: Small but handy function to emulate an Access-style DLookup function.



function DLookup($fld, $tab, $whr)
{
	$q = "Select $fld from $tab where $whr";
	$rst = mysql_query($q);	
	if ($row = mysql_fetch_object($rst)) 
		return $row->$fld;
	else
		return NULL;
}

// ex: lookup a customer name based on $customerid

$name = DLookup("Name", "Customer", "Id=$customerid");

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Brian Levine

Comment:



Comment:

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