dongqiulei6805 2018-05-29 16:36
浏览 53

如何在不使用分页的情况下返回相同的MySql记录

I have a MySql table with over 1000 products that I scroll through, I understand the SQL query below says "return only 10 records, start on record 16 and display the next 10 records"

sql =”SELECT * FROM items LIMIT 10 OFFSET 15”;

I could keep track of LIMIT and OFFSET within variables and use a pagination function to scroll through my table.

BUT I don’t want to use pagination. I just want to scroll up or down through all my records up or down, even if there where more than 1000 records, I don't care. So here is the problem, lets say product record 567 is displayed on page(A) and I have a link to another page(B) that displays more product information. Then I want to come back to page(A) to same spot, record 567 and be able to scroll up or down through my records. Even the records less than 567. This is why OFFSET is not necessarily what I need. Any Ideas would be great.

  • 写回答

1条回答 默认 最新

  • duanmu6752 2018-05-29 20:32
    关注

    If you just use the back button of the browser it's up to the browser to memorize the position and hopefully restore it. If you go back via link an page B use anchor links in page A and have the link in page B point at that. You have to pass the right link from page A to page B of course.

    E.g.:

    Page A:

    ...
    <a href="#4711">Product 4711</a>
    <a href="page_b.php?id=4711">View details</a>
    ...
    

    Page B:

    ...
    <h1>Product 4711</h1>
    (Description of product 4711)
    <a href="page_a.php#4711">Go back to the list of products</a>
    ...
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制