dsfw2154 2015-03-07 09:47
浏览 52
已采纳

使用计数器和不同数据重新加载页面的一般原则

The website I need to implement is for a simple user study: On a page there are some images shown, the user rearranges them to a certain order, hits the 'next' button and then the same page is shown again, just with different images, which the user rearranges again. The process is repeated until a certain page count is reached.

Which images to show, comes from a mysql database and the user arrangements for each page need to be stored in the database as well. I have decent code for the database communication and logic of the image arrangements in php. The ordering functionality of the images works nicely with javascript and jquery.

What is completely throwing me off now, is bringing it all together and the 'save and reload the page with different images' mechanism. Of course I found loads of information on the internet but I just can't bring it together (I am a noob with javascript and that stuff is seriously making my head hurt).

My question:

  • How do I implement a page, with a page counter, which is increased when I press a button; pressing the button also triggers sending the data to php for putting it in the database and also reloads/updates the page with a different image selection based on the page counter to re-start the process.

I would be most greatful for all: from explaining the general principles to specific code examples. I just need to make this thing work :). Thanks!

  • 写回答

1条回答 默认 最新

  • dongya9346 2015-03-07 10:01
    关注
    1. You need a < form method=POST > tag which wrapps all your images
    2. For each image you need a < input type="hidden" > tag which stores the image id. This tag must be resorted with the images as well.
    3. Resorting must change the position in the DOM
    4. you need a submit button as well
    5. On server side you can access the submitted data with $_POST variable in same sorting as in the DOM
    6. You can count the number pages in $_SESSION variable or send the counter as GET variable with the page url

    This is only a short overview, i hope this helps you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘