我在代码片段“searchcar.php”中收到此错误“警告:mysqli_fetch_assoc() 期望参数 1 为 mysqli_result, array given in”
$modelmake = $_POST['model_make'];
$result = $db->select('car_information','*', 'Model_Make LIKE \'%$modelmake%\'');
while($row = mysqli_fetch_assoc($result))
{
echo 'Model'.$row['model_make'];
}
这是来自“database.php”选择功能的代码片段
public function select(
$table,
$fields = '*',
$where = '1=1',
$order = '',
$limit = '',
$desc = false,
$limitBegin = 0,
$groupby = null,
$monitoring = false
) //monitoring is set to true to view the actual query
{
// $query ='SELECT ' . $fields . ' FROM ' . $table ;
$query = 'SELECT ' . $fields . ' FROM ' . $table . ' WHERE ' . $where;
if (!empty($groupby)) {
$query .= ' GROUP BY ' . $groupby;
}
if (!empty($order))
{
$query .= ' ORDER BY ' . $order;
if ($desc)
{
$query .= ' DESC';
}
}
if (!empty($limit))
{
$query .= ' LIMIT ' . $limitBegin . ', ' . $limit;
}
$result = $this->_sendQuery($query);
$resultArray = array();
while ($row = mysqli_fetch_assoc($result))
{
$resultArray[] = $row;
}
if ($monitoring)
{
// If monitoring is activated, echo the query
echo $query;
}
return $resultArray;
}
我想用这行“while($row = mysqli_fetch_assoc($result))”请指教!