Version: 1.0
Type: Function
Category: Databases
License: GNU General Public License
Description: This script is used when you have more than one table where names are stored. I created it so that I could get names of accounts, vendors, or payment types for a ledger program that are associated to a number. You pass to it a number as $acct and what type of name you want (i.e. Vendor, Account, Payment Type) as $type.
/*
This code comes from the PHP Function Junction at www.discountsexpress.com/PHPFJ
Gets Account and Payment Type names
$acct is the $ that holds the refered #
$type is a choice account:
accounts
pmt
vendor
*/
function fj_get_names($acct, $type)
{
if ($type=="accounts")
{
$result= mysql_query("select * from ledger_accounts where auto=$acct");
}
elseif ($type=="vendor")
{
$result= mysql_query("select * from ledger_vendors where auto=$acct");
}
elseif ($type=="pmt")
{
$result= mysql_query("select * from ledger_pmttype where auto=$acct");
}
if ($result)
{
while ($row = mysql_fetch_array($result))
{
return $row["name"];
}
mysql_free_result($result);
}
}