I have recently started to write server scripts. Although the question may seem to be very basic but i am not able to get a solution.
I have two tables one is PRODUCTS and the other is DEALS
PRODUCTS TABLE: Id product_name product_desc category brand 1 product1 desc1 cat1 brand1 2 product2 desc2 cat2 brand2 DEALS TABLE Id deal_name productid 1 todayoffer 2
I wish to put the value of id (from PRODUCTS table) into productid and carry this value to DEALS table and then add deal_name along with it as shown above. The recent code that i am using is
<? require_once('config.php'); //connection $dealname=$_REQUEST['dealname']; $productid=$_REQUEST['productid']; $id=$_REQUEST['id']; $productid=$_REQUEST['productid']; $inserts = mysql_query("insert into deals (dealname,productid) values ('".$dealname."','".$productid."') SELECT productid FROM products WHERE productid = '".$id."'"); $posts['message'] = 'Deal Registered'; $idd = mysql_insert_id(); $selectt = mysql_query("select * from deals where id = '".$idd."'"); $posts['detail'] = $selectt; header('Content-type: application/json'); echo json_encode($posts); ?>
I would really appreciate if anyone could guide me and tell me why i am not getting the result