0
我有一个SQL语句....查询后从数组中获取正确的数据?
"SELECT o.orderID, p.productID, p.name, o.qty, p.mouldID FROM products AS p INNER JOIN orderedProducts AS o ON o.productID = p.productID WHERE o.orderID = '$id'";
当我使用它在phpMyAdmin测试它,它看起来像这样(我用的ID 56)
__________________________________________
|orderID|productID|name |qty |mouldID|
|56 |11 |newproduct |2000|4 |
|56 |12 |newproduct2|10 |5 |
|56 |13 |newproduct3|5 |6 |
但数组被吐出的是:
Array ([0] => 56 [orderID] => 56 [1] => 11 [productID] => 11 [2] => newproduct [name] => newproduct [3] => 2000 [qty] => 2000 [4] => 4 [mouldID] => 4)
这不是我想要的数据,所以我想看到,如果我把它放到一个表,会发生什么
返回
0 | 56
orderID | 56
1 | 11
productID | 11
2 | newproduct
name | newproduct
3 | 2000
qty | 2000
4 | 4
mouldID | 4
显然事情错了......
我用mysql_fetch_array
从数据库中的数据进入阵列...这是什么也许我做错了吗?
基本上我希望它看起来像数据库返回的第一个表。
任何想法......谢谢!
'mysql_fetch_array()'一次只返回一行。您必须在循环中调用它以获取所有数据。 – Barmar 2013-03-26 15:45:12