Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mysql表中创建数组/列表并用PHP提取_Php_Mysql - Fatal编程技术网

在mysql表中创建数组/列表并用PHP提取

在mysql表中创建数组/列表并用PHP提取,php,mysql,Php,Mysql,所以,我正在创建我的第二个电子商务商店。在我创建的第一个存储中,我使用了一个数组来存储数据。以下是一个例子: $product = array(); $product = array(); $product[101] = array( "category" => "Clothes", "name" => "Caps - Stylize yours. Come in different colors.", "img" => "../img/clothes/caps/01.jp

所以,我正在创建我的第二个电子商务商店。在我创建的第一个存储中,我使用了一个数组来存储数据。以下是一个例子:

$product = array();
$product = array();
$product[101] = array(
"category" => "Clothes",
"name" => "Caps - Stylize yours. Come in different colors.",
"img"  =>  "../img/clothes/caps/01.jpg",
"price" => 9.95,
"paypal" => "TLYMXTX7DTCHL",
"color" => array("Navy","White","Hot Pink","Yellow Cap","Navy","Black","Coral")

我希望能够在我的数据库中存储颜色,并能够在HTML中选择它们,以便客户可以进行选择

最好使用1对多关系将颜色保存在单独的表中。将productId添加为外键。添加产品后,在颜色上为每种颜色写一个,添加到新表中


我相信这对未来也是一个很好的解决方案。

谢谢!我也这么想,但这让我很困惑,因为有库存。productId包含数量,但我想我可以将其保存到管理员控制商店中显示内容的位置。谢谢