I have been struggling to figure out the logic for a cross reference of data in my code. Any assistance is greatly appreciated!!!!
Here goes, I have 2 tables, tblPayments and tblProducts in my database. I am receiving data and am attempting to query tblProducts against the received item $item_number against Item_ID. I want to return a related field, File_Name, from that row. Here is the lines of code:
$query = "SELECT File_Name FROM tblProducts WHERE ('Item_ID' = $item_number)";
$result = mysql_query($query) or die ("Query failed");
$insert = "INSERT INTO tblPayments (receiver_email, item_name, item_number, quantity, invoice, custom, payment_status, payment_date, txn_id, first_name, last_name, address_street, address_city, address_state, address_zip, address_country, payer_email, payment_gross)
VALUES ('$receiver_email', '$item_name', '$item_number', '$quantity', '$invoice', '$result', '$payment_status', '$payment_date', '$txn_id', '$first_name', '$last_name', '$address_street', '$address_city', '$address_state', '$address_zip','$address_country', '$payer_email', '$payment_gross')";
mysql_query($insert) or die ("Could not add data to the table");
Can anybody help please? Thanks!