这里是堆栈的第一次用户。为这个冗长的标题道歉,但我不太确定该怎么说。所以这是我的设置。
在我的functions.php文件中,我有以下sql:
function getCustomersTable() {
$sql = "SELECT * FROM customers
LEFT JOIN leads on customers.customer_id = leads.customer_id
LEFT JOIN events on customers.customer_id = events.customer_id";
return resourceToTwoDimensionalArray(query($sql));
}
我将把查询中的某些数据插入到一个html表中。我的代码是:
$customers = $getCustomersTable();
foreach($customers as $customer) {
$id = $customer['customer_id'];
$title = $customer['event_title'];
$pickup = $customer['pickup_time'];
$pickupLocation = $customer['pickup_instructions'];
$totalPassengers = $customer['num_passengers'];
// Print the data to the table
echo "
<td>$title</td>
<td>$pickup</td>
<td>$pickupLocation</td>
<td>$totalPassengers</td>
";
当我运行它时,我在$customers=$getCustomersTable()上得到一个致命错误"函数名必须是字符串";
有什么想法吗?
非常感谢!
$customers = $getCustomersTable();
^----
您正在尝试使用一个变量函数,其中包含一个未定义的变量。由于变量是未定义的,它基本上相当于
$customers = null();