2018-08-17 09:28
浏览 82


I'm building an image slider where images are loaded from my database and displayed inside a php page.

There's a session variable, "number", to remember what is the current database row, in this way I can easily move to next or previous image.

Initially the page was working perfectly, but now when I press on "Next" button to increase session number and move to next page, it remains stuck to "2" and doesn't allow me to read other pages, even if there are multiple ones. I can only browse image no. 1 and image no. 2

I believe the code is correct, but I'm afraid there's something missing about how PHP sessions works, can you confirm it?


图片转代码服务由CSDN问答提供 功能建议



最初页面工作正常,但现在当我按下“下一步”按钮增加会话编号并转到下一页时,它仍然停留在“2”并且不允许我读取其他页面,即使有多个页面 那些。 我只能浏览图片号。 1和图像号。 2


/ /

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doupo5861 2018-08-17 09:55

    session_start() must be the second thing on your page after <?php. HTML tags must be placed after it or the session will not be started.

    打赏 评论
  • douliao8402 2018-08-17 09:51

    You do not need to use Session to maintain the pagination, instead Keep the pagination status inside Next, Prev html buttons. I could see some better pagination logic here at:

    Simple PHP Pagination script

    打赏 评论

相关推荐 更多相似问题