Skip navigation links

MySQL Forums :: PHP :: How to populate one table with values from another table


Advanced Search

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?

[PHP]
<?php

include('db_connect.php');

session_start();

$username = $_SESSION['username'];

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

$prod_name=$_POST['prod_name'];
$prod_brand=$_POST['prod_brand'];
$prod_price=$_POST['prod_price'];
$cat=$_POST['cat'];
$subcat=$_POST['subcat'];
$prod_w_c=$_POST['prod_w_c'];
$url='add_prod.php';

$row=mysql_fetch_array($sql);

$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>";

?>
[/PHP]

Options: ReplyQuote


Subject Written By Posted
How to populate one table with values from another table Sandeep Bhugoo 06/26/2013 11:11PM
Re: How to populate one table with values from another table Peter Brawley 06/27/2013 11:14AM


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.