#native_company# #native_desc#
#native_cta#

Access Style DLookup function for MySQL

By Brian Levine
on 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");