$query = mysql_query("SELECT `code`, `file` FROM `files` WHERE id >= '$idimg' ORDER BY id ASC LIMIT 1, 8");
while ($result = mysql_fetch_assoc($query)) {
if (strlen($result['title']) < 12) {
echo '<div id="recomimage5"><div id="linkstyle"><strong><a href="http://localhost/edu/1111111111111/download.php?code='. $result['code'] . ' "><img src="files/thumbs/' . $result['code'] . '/' . $result['file'] . '" alt="' . $result['title'] . '"></a></strong></div></div>';
}
else {
echo '<div id="recomimage5"><div id="linkstyle"><strong><a href="http://localhost/edu/1111111111111/download.php?code='. $result['code'] . ' "><img src="files/thumbs/' . $result['code'] . '/' . $result['file'] . '" alt="' . $result['title'] . '"></a></strong></div></div>';
}
}
I order eight images from a MySQL database.
Result this query:
My id images for example is '5'
Results now is: '6' '7' '8' '9' '10' '11' '12' '13' // id numbers images
But I want a result like this - for example my images in reloaded page is '5'
Result must be: '1' '2' '3' '4' '5' '6' '7' '8' // id numbers images
LIMITclause?SELECT code, file FROM files WHERE id >= '$idimg' ORDER BY id ASC LIMIT 8WHEREclause toWHERE id >= $idimg - 4. Note: This is assuming$idimghas been sanitized.idis of type varchar, you may need to cast it for substraction.WHERE CAST(id AS UNSIGNED) >= CAST(id AS UNSIGNED) - 4