3 回答
TA贡献1831条经验 获得超10个赞
您必须添加名为“GalleryID”或类似内容的列,并从搜索查询中获取 GalleryID,然后按 GalleryID 选择所有照片并按 ID 对它们进行排序,现在您有了已排序的照片列表,例如:
$queryResult = $db->query("SELECT GalleryID FROM table WHERE name LIKE '%WHAT I WANT%'")->fetchall();
$GalleryID = $queryResult[0]['GalleryID'];
$photos = $db->query("SELECT ID FROM table WHERE GalleryID = $GalleryID order by ID asc")->fetchall();
现在你可以玩 INDEX;
$index = 0; // Current photo index
//Get next photo
$index++;
if($index < count($photos))
$photoUrl = $db->query("select url from table where ID = $photos[$index] limit 1");
// Get the previous photo
$index--;
if($index >= 0)
$photoUrl = $db->query("select url from table where ID = $photos[$index] limit 1");
- 3 回答
- 0 关注
- 232 浏览
添加回答
举报