sql函数语句w在php中通过变量赋值连接并调用指定的记录

sql函数语句w在php中通过变量赋值连接并调用指定的记录,php,mysql,sql,Php,Mysql,Sql,这里是stack的第一次用户。我为这个冗长的标题道歉,但我不确定该怎么说。这是我的设置 在我的functions.php文件中,我有以下sql: function getCustomersTable() { $sql = "SELECT * FROM customers LEFT JOIN leads on customers.customer_id = leads.customer_id LEFT JOIN events

这里是stack的第一次用户。我为这个冗长的标题道歉,但我不确定该怎么说。这是我的设置

在我的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();