MySQL Forums
Forum List  »  PHP

How to populate one table with values from another table
Posted by: Sandeep Bhugoo
Date: June 26, 2013 11:11PM

i have a table with the following columns

pord_name, prod_brand, prod_photo, prod_desc

and another table with the following columns

prod_name, prod_brand, prod_photo, prod_desc, cat, subcat, prod_price, prod_w_c

i have a for add_prod.php to add products

the prod name is displayed in a select which when product name is selected, populates the prod brand select. on selecting an option in the prod brand, the prod desc is displayed

when i click on the add button, prod_name, prod_brand, etc are added except the prod_desc and prod_photo

can i know what is wrong with the code here please?




$username = $_SESSION['username'];

$sql=mysql_query("select user_id from tbllogin where username = '$username'");



$sql=mysql_query("INSERT INTO tbl_product(user_id, prod_name, prod_brand, prod_desc, prod_price, cat, subcat, prod_w_c) VALUES('$row[user_id]', '$prod_name', '$prod_brand', '$prod_desc', '$prod_price', '$cat', '$subcat', '$prod_w_c') SELECT FROM tbl_prodstd (prod_photo, prod_desc) WHERE prod_name='$prod_name'");

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
echo "<script>alert('This product has been added successfully.')</script>";


Options: ReplyQuote

Written By
How to populate one table with values from another table
June 26, 2013 11:11PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.