here i have two tables pro_zone_m and temp_const and i am inserting values into third table pro_m where i will be inserting zone from temp_const, and i need to get value of zone_id of corresponding zone from pro_zone_m. i tried but could'nt able to come up with solution.
$uisq = "SELECT * FROM pro_zone_m";
$ytu = mysql_query($uisq);
$mnm = mysql_fetch_array($ytu);
extract($mnm);
$wqr = "SELECT * FROM temp_const";
$wqe = mysql_query($wqr);
while($wqe1 = mysql_fetch_array($wqe))
{
extract($wqe1);
$zxc = "INSERT INTO pro_m set custid='$custid', firstname='$firstname', lastname='$lastname', country='$country',
city='$city', state='$state', zone='$zone', adresstype='$address_type', address1='$address1', address2='$address2',category='$category',
focus='$focus', assignto='$assign_to', division='$division', product='$product', grade='$grade', potential='$potential', designtn='$designation',
mobile='$mobile', primphone='$primary_phone', primemail='$primary_email',
exhibition = '$exhibition', zonea_id = '$zoneid' WHERE zone = '$code' ";
$zxc1 = mysql_query($zxc);
Update your insert query like this:(assuming zonea_id will store zone_id from temp_const table.
$zxc = "INSERT INTO pro_m set custid='$custid', firstname='$firstname', lastname='$lastname', country='$country', city='$city', state='$state', zone='$zone', adresstype='$address_type', address1='$address1', address2='$address2',category='$category', focus='$focus', assignto='$assign_to', division='$division', product='$product', grade='$grade', potential='$potential', designtn='$designation', mobile='$mobile', primphone='$primary_phone', primemail='$primary_email', exhibition = '$exhibition', zonea_id = (SELECT zone_id FROM temp_const where zone = '$code') ";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.