本文介绍了如何在数据库行中插入多个产品/文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的数据库行中插入多个产品,例如:
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.
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!
推荐答案
这篇关于如何在数据库行中插入多个产品/文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!