I have 2 tables in MySQL.
One is a list of shops, which has a ShopID,ShopName,Phone,DisplayAddressID.
Another table is a list of Addresses, with details such as AddressID,AddressLine1,AddressLine2, Suburb, Zip, State etc.
I have some php code which gives me the shopid, with a new address to update in the db.
Currently to update the address I do the following:
$ShopAddrID = mysql_query("SELECT DisplayAddressID FROM shops WHERE ShopID='$shopid'");
$result=mysql_fetch_array($ShopAddrID);
$ShopAddrID = $result[0];
mysql_query("UPDATE addresses SET AddressLine1='$AddressLine1',AddressLine2='$AddressLine2',City='$City',Postcode='$Postcode',State='$State'WHERE AddressID='$ShopAddrID'");
2 questions:
1) If I am pulling only 1 field from a mysql_query, can I reference it easier/simpler? ie. 1 line of code rather than 3.
2) Can I update the address with just one mysql statement?
I want the code to be efficient and simple.
Thanks in advance.