Reputation: 2709
The sql calc found rows in mysqli is not returning the exact number of records (numrange). I get : 1. It should work fine.
$sQuery1 = "SELECT SQL_CALC_FOUND_ROWS
sv_cam.image,
sv_cam.cam_id,
sv_cam.alt,
sv_orte.resort,
sv_orte.resort_us,
sv_country.sym,
DATE_FORMAT(sv_cam.lud, '%b %d') as stat
FROM sv_cam
LEFT JOIN sv_orte ON sv_cam.res_id = sv_orte.res_id AND status=0
INNER JOIN sv_canton ON sv_orte.can_id = sv_canton.can_id
INNER JOIN sv_country ON sv_canton.cou_id = sv_country.cou_id
WHERE (lud >= DATE_SUB('$today', INTERVAL 30 DAY)) ORDER BY lud desc, sv_cam.cam_id desc LIMIT $offset, $cams";
//echo $sQuery1;
$sResult1=mysqli_query($conn, $sQuery1);
$numrows = mysqli_num_rows($sResult1);
//if ($numrows<1) { exit; }
$numrange=mysqli_query($conn,"SELECT FOUND_ROWS()");
echo $numrange;
Upvotes: 0
Views: 210
Reputation: 92805
mysql_query()
function returns the mysqli_result
object. Therefore you need to fetch your results.
$sResult2 = mysqli_query($conn, 'SELECT FOUND_ROWS() AS total');
$found_rows = mysqli_fetch_object($sResult2);
echo 'total rows'.$found_rows->total;
Upvotes: 1