hi guys, i have 2 tables - tblproduct and tblretprod.
i insert my product details to tbl product with prod_id being auto increment
other fields are prod_name, prod_brand, prod_desc, prod_photo, cat, subcat
i hv another table tblretprod with fields id, user_id, prod_id, prod_price
i can add my products successfully
i am displaying all the products i added in a table i echo along with a textfield to enter the product price and an add button
on clicking the add button, user_id for the session, prod_id and prod_price should be inserted in the tblretprod
user_id and prod_price are being inserted correctly, but the prod_id which is unique to each product is not being added. only the first prod_id i.e 1 is being added everywhere
here are my codes to add the product when i click on add
<?php
session_start();
include('db_connect.php');
$username = $_SESSION['username'];
$prod_price = $_POST['prod_price'];
$url='retprod.php';
$sql=mysql_query("select user_id from tbllogin where username = '$username'");
$row = mysql_fetch_array($sql);
$sql1 = mysql_query("select * from tblproduct where prod_id='$prod_id'");
$row1 = mysql_fetch_array($sql1);
$sql2 = mysql_query("insert into tblretprod (user_id, prod_id, prod_price) values ('$row[user_id]', '$row1[prod_id]', '$prod_price')");
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
echo "<script>alert('This product has been added successfully.')</script>";
?>