我正在开发一个程序并提出了一些烦人的问题。我正在尝试显示数组中的数据。我从我设置的另一个数组中复制了格式,它运行良好。唯一的区别是我正在收集更多数据......
调用函数:
$data1 = display_orders($_SESSION['user_id'], $limit, 'fName', 'lName', 'VendorName', 'DateRequested', 'Shipping', 'VendorNumber', 'VendorFax', 'VendorAddress', 'VendorCity', 'VendorState', 'VendorZip', 'EquipmentConsumable', 'GasType', 'GasLocation', 'UNMTag', 'EquipmentLocation', 'index', 'totalcost', 'Approved', 'Shipped');
函数本身
<?php
function display_orders($user_id, $limit)
{
$data = array();
$user_id = (int)$user_id;
$limit = (int)$limit;
$func_num_args = func_num_args();
$func_get_args = func_get_args();
// print_r($func_get_args);
if ($func_num_args > 1)
{
unset($func_get_args[0]);
unset($func_get_args[1]);
$fields = '`' . implode('`, `', $func_get_args) . '`';
for($x = 0; $x < $limit; $x++)
{
$data[] = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `users` , `vendor` WHERE $user_id = users.id AND $user_id = vendor.user_id ORDER BY vendor.DateRequested DESC"));
}
return $data;
}
}
?>
所以现在我尝试回显数据:
echo $data1['VendorName'];
我没有输出。
如果我执行以下操作:
print_r ($data1);
我得到输出!
Array ( [0] => Array ( [fName] => admin [lName] => test [VendorName] => Newegg [DateRequested] => 2013-09-19 [Shipping] => Standard [VendorNumber] => NA [ VendorFax] => NA [VendorAddress] => NA [VendorCity] => NA [VendorState] => NA [VendorZip] => 00000 [EquipmentConsumable] => 设备 [GasType] => [GasLocation] => [UNMTag] => 0 [设备位置] => 计算机实验室 [索引] => 0 [总成本] => 39.99 [已批准] => 0 [已发货] => 0 ) )
但是,如果我尝试添加字段名称 No data....
任何帮助,我将不胜感激!