我现在有以下数组,PHP/Mysql使用现有数组中的值创建一个新数组,帮助?
Array (1) 0 => Array (5) productid => 1 qty => 1 materialid => 12
和我有以下两个查询其是
select name as productname, price from products where productid=1
和
select name from materials where materialid=12
我需要这些查询链接,使得阵列输出是这样或类似的:
Array (1) 0 => Array (5) productid => 1 qty => 1 materialid => 12 productname => Toothbrush price => £3.00
这基本上是将内容输出到购物篮页面。请注意,查询无法连接,因为两个表上没有任何连接。
谢谢
[PHP的array_merge(http://php.net/manual/en /function.array-merge.php)可以为你做这个 –
输出数组不包含来自第二个查询的数据,只包含来自第一个查询的产品名称和价格。 – Kwebble