sql 语句显示从 30 到 50 的每个年龄的员工,DOB 仅在 db/my sql 查询中:
$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");
在 sql 中工作正常。但是当我在 php 中使用此查询时,它无法正常工作,同时运行此命令:
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++;
我收到一个错误 mysql_fetch_array() 期望参数 1 是资源,布尔值帮助我..