Here is my Model in Codeigniter with foreach loop in it.
Function.
public function get_projectcount($qup) {
echo'[';
foreach ($qup as $row) {
$id = $row['myid'];
$this->db->select('*');
$this->db->from('projects');
$this->db->where(array('projects.accountId' => $id));
$query = $this->db->get();
$projects_count = count($query->result());
echo '{"myid":"' . $row['myid'] . '",';
echo '"total_projects":"' . $projects_count . '"},';
}
echo']';
}
I want this as a result of json_encode.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…