How to pass session value in foreach loop php
<p>it's a basic thing, but i am not able to get the required data. below is the code, while fetching count of absent from DB with logged in user id (empid=933) it's giving me the required record. but i want to fetch the same data with session ID of logged id user which is already created as $empid. but i am not able to pass this session value in below mentioned query. any one can help, i would appreciate ... thanking you in advance.</p>

<pre><code>&lt;?php
$hostname="localhost";  
$username="root";  
$password="";  
$db = "usman";  
$dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password);  

foreach($dbh-&gt;query('SELECT COUNT(*) FROM ams where empid= 933 GROUP BY leavetype HAVING leavetype = "Absent"   
 ') as $Absent) 
{  
echo "&lt;td&gt;" . $Absent['COUNT(*)'] . "&lt;/td&gt;";
echo "&lt;br&gt;"; 
}
?&gt;
</code></pre>