Click here to Skip to main content
13,147,956 members (97,564 online)
Rate this:
Please Sign up or sign in to 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>


Here is my Code for retrieving the values, but when i add it to my database, the first product name will only be added.
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))
	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 4-Feb-13 18:57pm
Updated 4-Feb-13 19:24pm

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100