<?php
require_once 'connect_db.php';
function getCatalog($type) {
global $mysqli;
connectDB();
$where = "WHERE `type`=".$type;
$result = $mysqli->query("SELECT * FROM `projects` $where ORDER BY `id` DESC");
closeDB();
return resultToArray_catalog($result);
}
function resultToArray_catalog($result){
$array = array();
while (($row = $result->fetch_assoc()) != false)
$array[] = $row;
return $array;
}
Ошибки
Fatal error: Uncaught Error: Call to a member function fetch_assoc() on boolean in /Applications/MAMP/htdocs/mebel/admin/functions/database_catalog.php:14 Stack trace: #0 /Applications/MAMP/htdocs/mebel/admin/functions/database_catalog.php(10): resultToArray_catalog(false) #1 /Applications/MAMP/htdocs/mebel/catalog.php(7): getCatalog('kuhnya') #2 {main} thrown in /Applications/MAMP/htdocs/mebel/admin/functions/database_catalog.php on line 14
<?php
$title = "Каталог работ | KINGWOOD";
include "header_two.php";
require_once 'admin/functions/database_catalog.php';
$type = $_GET['type'];
$catalog = getCatalog($type);
print_r($catalog);
?>