Page 1 of 1

Lookup field ID

Posted: 2020-09-30 00:03
by mdspine
I have a Invoice Table (with 3 fields InvoiceID, InvoiceDate, CustomerLookup) .
The CustomerLookup is a lookup field of Customer Table which has 2 fields(CustomerID, CustomerName)

I need to get the CustomerID of the customer from a given InvoiceID

$Invoice_from = get_sql_from('Invoice');
$Invoice_id = intval($_REQUEST['InvoiceID']);
$Invoice_fields = get_sql_fields('Invoice');
//Need the syntax to get CustomerID for a given InvoiceID

Re: Lookup field ID

Posted: 2020-09-30 06:10
by pbottcher
Hi,

acutally, if you need the CustomerID, this is the data stored in the CustomerLookup field of the Invoice table.

SELECT CustomerLookup from Invoice where InvoiceID = ID_YOU_SEARCH_FOR

Re: Lookup field ID

Posted: 2020-09-30 12:03
by mdspine
Appreciate it will try

Re: Lookup field ID

Posted: 2020-09-30 23:38
by mdspine
Hi
I used

Code: Select all

$IDofPatient=SELECT PatLU from Billing where BillingID = 2;	
echo $IDofPatient;
I get this error
Parse error: syntax error, unexpected 'CustomerLookup' (T_STRING) in /mydomain/TEST.php on line...
Please advise

Re: Lookup field ID

Posted: 2020-10-01 01:22
by mdspine
Sorry

Code: Select all

$IDofCustomer=SELECT CustomerLookup from Invoice where InvoiceID = 2;	
echo $IDofCustomer;

Re: Lookup field ID

Posted: 2020-10-01 21:03
by mdspine
I was able to figure that out
it should be

Code: Select all

$IDofCustomer= sqlValue("select CustomerLookup from {$Invoice_from} and InvoiceID= {$Invoice_id}", $eo);
The key as sqlValue instead of sql

Thanks