小编Nis*_*tel的帖子

需要帮助使用PHP在mysql数据库中插入逗号分隔数据

数据库表中已有的演示数据:

INSERT INTO `csvtbl` (`ID`, `SKU`, `Product_Name`, `Model`, `Make`, `Year_From`, `Year_To`) VALUES
(1, 'C2AZ-3B584-AR', 'Power Steering Pump Seal Kit (Eaton Pump)', 'Galaxie', 'Ford', '1960', '1965'),
(2, 'C2AZ-3B584-AR', 'Power Steering Pump Seal Kit (Eaton Pump)', 'Thunderbird ', 'Fordtrest', '1960', '1965');
Run Code Online (Sandbox Code Playgroud)

我使用下面的代码并插入年份,并在表格中分隔逗号(,):

INSERT INTO `diff_yearstbl` (`ID`, `SKU`, `Product_Name`, `Model`, `Make`, `Year`) VALUES
(1, 'C2AZ-3B584-AR', 'Power Steering Pump Seal Kit (Eaton Pump)', 'Galaxie', 'Ford', '1960,1961,1962,1963,1964,1965'),
(2, 'C2AZ-3B584-AR', 'Power Steering Pump Seal Kit (Eaton Pump)', 'Thunderbird ', 'Fordtrest', '1960,1961,1962,1963,1964,1965');
Run Code Online (Sandbox Code Playgroud)

年份数据运行良好,但我想插入数据Make和Model与Year相同,但这次只是使用逗号(,)将数据插入一行,如下例所示,使用SKU字段.因此需要将上述两条记录合并为一行,如下面的记录.

INSERT INTO `diff_yearstbl` (`ID`, …
Run Code Online (Sandbox Code Playgroud)

php mysql database arrays

6
推荐指数
1
解决办法
719
查看次数

{$ foo | @print_r}在屏幕上打印'{$ foo | @print_r}'

我想打印数组变量 $foo.所以我做了{$foo|@print_r}这个,但它的打印就像"{$foo|@print_r}"在头版.

我正在使用Oxied eshop,它使用smarty作为模板引擎.

php smarty

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

php ×2

arrays ×1

database ×1

mysql ×1

smarty ×1