PHP mysql数据库排序


php mysql database order by

$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>';   
    }
}

我从MySQL数据库中订购了8张图片。

查询结果:

例如我的id图像是'5'

Results now is: '6' '7' '8' '9' '10' '11' '12' '13' // id numbers images

但我想要这样的结果-例如我的图像在重新加载的页面是'5'

Result must be: '1' '2' '3' '4' '5' '6' '7' '8'     // id numbers images

请参考http://dev.mysql.com/doc/refman/5.0/en/select.html