drkbpwk609294 2012-07-06 13:38
浏览 30

SQL,PHP和jQuery动态评论系统

I'm setting up an under construction page for my new website.

I'll try to explain:

  • There are 3 Columns side by side
  • When a new comment is 'retrieved' it is added to the first column
  • For each comment - if bottom > 300px from top of column: copy, delete and prepend to next column (just delete if column:last)

The above I have working fine, but riddle me this:

  • How can I do the opposite and add older comments to the end
  • A comment can vary in height depending on the message, this means there isn't a fixed amount of comments on show.
  • There are 'newer comments' and 'older comments' links. I would like these to retrieve comments posted after or before the newest comment shown or oldest comment shown respectively.

The idea is to repeat the 'retrieve comment' procedure 6 times, getting 6 newer/older comments and prepending/appending to the first/last column respectively. I would need to keep track of the newest comment and oldest comment being displayed for the php script to know which comment to retrieve next (returned via AJAX).

I may have over complicated things but it would be fantastic if anyone can just come up with a solid algorithm for me to follow. I'm not asking anyone to program it for me, that would take the fun out! ;D

My attempt at a drawing:

My attempt at a drawing

  • 写回答

1条回答 默认 最新

  • douzi8916 2012-07-06 19:45
    关注

    I'm not sure if this will help you, but you can set up an array of objects to track their order and to manage if they are visible or not. When you fetch newer comments, add them to the front of the array using unshift, and when you fetch older comments, add them to the end of the array using push. You can set this up in the oncomplete callback of your AJAX function. The array might look something like this:

    var comments = [
                       {id: 'comment8', visible: true},
                       {id: 'comment9', visible: true},
                       ...
                    ]
    

    The id for each object could correspond to the id of the Comment Container, so you can retrieve these values and use them in your jquery selectors to do whatever you need to do.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据