在如何实现这一点上遇到了困难。。。。。
我有一个PHP页面,它显示了表中一条记录的信息。这些记录包括唯一密钥(image_id)和名称(image_name)。
为了显示正确的记录,我在上一页上使用了一个搜索功能,该功能会产生一个URL参数(imageinfo.php?image_id=1等)。
我的问题是,我希望在表中添加向前和向后箭头,以循环浏览不同的记录,但基于"image_name"的字母顺序,而不是"image_id"的数字顺序。
我真的不知道如何做到这一点,所以任何帮助都将不胜感激。
类似的内容:(我希望评论能解释)
<?php
$data = array(
123 => "B",
321 => "C",
124 => "A"
);
$id = 123; // This is the current image id
asort($data); // Sort the array based on values (names)
// Advance the internal pointer until it points to the current image
while(current($data) != $data[$id])
next($data);
// TODO: Also check whether next is past end here
echo next($data); // Should be C