Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to insert multiple products in my database row, For Example:
Purchase Serial:      Products Purchased:

      1                Lenovo Z370-59306340
                       Apple MacBook Air MC505 ZP/A 128GB
      
      2                <product>
                       <product>
                       <product>

--------------------------------------------------------------------------

Here is my Code for retrieving the values, but when i add it to my database, the first product name will only be added.
PHP
foreach($_SESSION['cart'] as $key=>$value)
       {
	$prodid = $value['productid'];
	$qty = $value['qty'];
	$result = mysql_query("SELECT name FROM products WHERE serial = $prodid");
	          while($row = mysql_fetch_array($result)) 
                  {
                   //echo "Name:".$row['name']."<br>Product ID:".$prodid."<br>Quantity:".$qty."<br><br>";
	           $products = $row['name'];
		  }
	$query="UPDATE user_transaction SET product_name = '$products' WHERE serial = 8";
	if (mysql_query($query, $con))
	 {
	   mysql_close($con);
	 }
	else
	die('Error: ' . mysql_error());


What could be the best solution for my problem?

I'm hoping that you guys will help me, though I'm searching in the internet but I can't find any solution.

Thanks and Regards!
Posted
Updated 4-Feb-13 19:24pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900