0

I use the top table as a cart for 1 customer, and the bottom table for order.

I wanted to get the productprice, productname, productqty and put it into orderdetail field.

Help and suggestions are very much appreciated.

Thanks in advance.

*attached a pic of the tables.

Edited by ken.atienza: n/a

Attachments asdf.png 53.72 KB
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by foreshadowed
0

assuming the field will be a valid type, you can query the first table for those fields, and then insert them into the second table. in php

$res = mysql_query("select productprice, productname, productqty from table_name where id='" . $target . "' limit 1;") or die(mysql_error());
if(mysql_num_rows($res) == 1) {
   $row = mysql_fetch_array($res);
   $insert = $row['productprice'] . $row['productname'] . $row['productqty'];
   $sql = mysql_query("insert into table_name values('', 'name', '" . $insert . "', 'amount');") or die(mysql_error());
}

You'd probably want/need to format $insert before inserting it. If you're using something like phpadmin, then I *think* you'd just use the sql syntax in a query box; It's been a while since I've coded any of this type stuff, but hopefully it's along those lines.

HTH

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.