There are three tables from which you need to display data. All you need to shove in an array and then display. It is necessary to check if the count in the request is 0, then enter the text and allow no orders.

class Statistics { public $connection = null; public $result = array(); public function __construct() { $this->connection = new mysqli('localhost','root','','mydb'); $this->connection->set_charset('utf8'); $this->get_statistics(); } public function get_statistics () { if(!$this->connection->connect_errno) { /* Заказ */ $order_query = $this->connection->query("SELECT count(*) FROM orders"); if($order_query->num_rows != 0) { $order_result = $order_query->fetch_array(MYSQLI_NUM); if($order_result[0] != 0) { $this->result[0] = $order_result[0]; } else { $this->result[0] = 'Нет заказов'; } } /* /Заказ */ /* Отзывы */ $review_query = $this->connection->query("SELECT count(*) FROM reviews"); if($review_query->num_rows > 0) { $review_result = $review_query->fetch_array(MYSQLI_NUM); if($review_result[0] != 0) { $this->result[1] = $review_result[0]; } else { $this->result[1] = 'Нет отзывов'; } } /* /Отзывы */ /* Скидка */ $discount_query = $this->connection->query("SELECT count(*) FROM users"); if($discount_query->num_rows != 0) { $discount_result = $discount_query->fetch_array(MYSQLI_NUM); if($discount_result[0] != 0) { $this->result[2] = $discount_result[0]; } else { $this->result[2] = 'Нет желающих получить скидку'; } } /* /Скидка */ } } } 

    2 answers 2

    Why do you need $ this-> connection-> query ("SELECT count (*) FROM discount"); code can be done

     $arr = $query->fetch_array(MYSQLI_NUM); if($arr != null && count($arr) > 0) { echo 'Заказы есть!'; } else echo 'Заказов нет!'; 

      I do the counting in my application as follows:

       $zapros=mysql_query("SELECT COUNT(id) FROM table_name"); $data=mysql_fetch_array($zapros); if ($data[0]==0) { echo 'Заказов нет!'; } else { }