$res = mysqli_query($conn, 'SELECT * FROM aaWHERE tags like "%123%" and wid = 46 and `createtime` >= UNIX_TIMESTAMP( "'.$start_date.'" ) AND `createtime` <= UNIX_TIMESTAMP( "'.$end_date.'" ) ORDER BY id DESC');
echo '<p>本月已完成:',mysqli_num_rows($res);
echo'本月任务500,还差';
上面的代码。现在能够查到本月完成的数目。现在就是想输出本月任务减去完成数目。输出结果。怎么弄。
类似这样写
$res = mysqli_query($conn, 'SELECT * FROM aaWHERE tags like "%123%" and wid = 46 and `createtime` >= UNIX_TIMESTAMP( "'.$start_date.'" ) AND `createtime` <= UNIX_TIMESTAMP( "'.$end_date.'" ) ORDER BY id DESC');
$ywc=mysqli_num_rows($res);
$rw=500;
$wwc=$rw-$ywc;
echo '<p>本月已完成:',mysqli_num_rows($res);
echo '本月任务',$rw,',还差',$wwc;
$res = mysqli_query($conn, 'SELECT count(*),500- count(*) FROM aaWHERE tags like "%123%" and wid = 46 and `createtime` >= UNIX_TIMESTAMP( "'.$start_date.'" ) AND `createtime` <= UNIX_TIMESTAMP( "'.$end_date.'" ) ORDER BY id DESC');
echo '<p>本月已完成:'.mysqli_fetch_row[$res][0];
echo'本月任务500,还差'.mysqli_fetch_row[$res][1];
直接在sql计算