タイプに基づいて、私は次の表カウントし、表示結果CodeIgniterの
|id|user_type|
|1|Customers|
|2|Suppliers|
|3|Customers|
|4|Suppliers|
|5|Suppliers|
|6|Employees|
を持っている私は、総顧客数をカウントしたい、サプライヤー、employess
は私のhtml
ある従業員 <a href="#" class="customers list-group-item">
<span class="badge badge-info">
2
</span>
Customers
</a>
<a href="#" class="employees list-group-item">
<span class="badge badge-danger">
3
</span>
Employees
</a>
<a href="#" class="suppliers list-group-item">
<span class="badge badge-success">
1
</span>
Suppliers
</a>
マイクエリコードは、このコードが動作しません。この
<?php
$this->load->model("User_model");
$query = $this->db->query('SELECT user_type, COUNT(Customers) AS total FROM `users` GROUP BY user_type');
if ($query->num_rows() > 0)
foreach ($query->result() as $row)
$data['users'] = array(
'total' => $row->total,
);
echo $data['users'];
のように見えます。あなたの時間をありがとう。
で実行されます。各データの繰り返しで$ data ['users'] 'が上書きされます。 1054 不明列USER_TYPE BY users' GROUP 'FROM jobcount AS 'フィールドリスト' SELECT USER_TYPE、COUNT(顧客)の「お客様が –