sql statement that shows the employees for each age from 30 to 50 , DOB is only in db / my sql query:
$sql = "SELECT age AS Age, count( * ) AS no. of employees FROM ( SELECT year( curdate( ) ) - year( dob ) AS age FROM emp ) AS x WHERE age >=30 AND age <=50)"
$result = mysqli_query($con,"$sql");
is working fine in sql. but when i am using this query in php it is not working as, while runnig this command :
while ($row = mysql_fetch_array($result)) { // This is new code
if($counter <=10){
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "</tr>";
$counter++;
i am getting an error mysql_fetch_array() expects parameter 1 to be resource, boolean help me ..