I have two tables one is PRODUCTS and the other is DEALS.
Expand|Select|Wrap|Line Numbers
- 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
Expand|Select|Wrap|Line Numbers
- <?
- require_once('config.php'); //connection
- $dealname=$_REQUEST['dealname'];
- $productid=$_REQUEST['productid'];
- $productid=$_REQUEST['productid'];
- $id=$_REQUEST['id'];
- $inserts = mysql_query("insert into deals (dealname,productid) values ('".$dealname."','".$productid."') SELECT productid FROM products WHERE productid = '".$id."'");
- $posts[0]['message'] = 'deal Added';
- $idd = mysql_insert_id();
- $selectt = mysql_query("select * from deals where id = '".$idd."'");
- $results = mysql_fetch_assoc($selectt);
- $posts[0]['detail'] = $results;
- header('Content-type: application/json');
- echo json_encode($posts);
- ?>