Hi,

how to write the MYSQL Query

select count(*) from (SELECT user_id FROM `reports` group by report_id) as tb where tb.user_id=5

in Cakephp inside the Loop

$users=$this->User->find('all');
    		
    		foreach($users as & $user):
                        //for each $user['User']['user_id']; which gives the User ids as 1 2 3 4 5 ...

              endforeach;

   			 $this->set('users', $users);

You got the connection? try this-

$this->User->query("select count(*) from (SELECT user_id FROM `reports` group by report_id) as tb where tb.user_id=5");

There is no difference. In both cases the variable is not set.
But this one looks better

php Code:

Original - php Code
echo "<TD><a href="searchfromlist.php".$myrow[""]."">search another</a>";

   1.
       
   2.
      echo "<TD><a href="searchfromlist.php".$myrow[""]."">search another</a>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.