Results 1 to 4 of 4

Thread: Virtual Pagination with PHP5

  1. #1
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Virtual Pagination with PHP5

    1) Script Title: Virtual Pagination

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...pagination.htm

    3) Describe problem: I am using the Virtual Pagination script with a PHP5 query statment. The problem that I am experiencing is that the pagination links always produce an additional blank page link at the end. i.e. <Prev 1234 Next> with pagination link 4 being a blank page.

    Does anyone have any ideas. My query statement is below. Thnak you for your help.

    $xajax->register(XAJAX_FUNCTION, 'dataInitiate');
    function dataInitiate(){
    $objResponse = new myXajaxResponse();
    $pp = "10";
    $total_kbs = mysql_query("SELECT * FROM ca_kb_master ORDER BY title");
    $total =mysql_num_rows($total_kbs);
    $rowcount = "<center>The Search Found <strong>".$total."</strong> Record(s)</center>";
    $total_pages = ceil($total/$pp);
    for ($i=0; $i<=$total_pages; $i++){
    $start = $pp * $i;
    $kbs = mysql_query("SELECT * FROM ca_kb_master ORDER BY title LIMIT $start, $pp");
    $html .= "<div class='virtualpage'>";
    while($row = mysql_fetch_array ($kbs))
    {
    $html .= "<div><br /><strong><a href='".$row['url']."' target='_blank' class='datatitlelink'>".$row['title']."</a></strong><br />".$row['description']."<br /><a href='".$row['url']."' target='_blank' alt='".$row['url']."' class='kblink'>".substr($row['url'], 0, 75)."</a><br /><a href='".$row['url']."' target='_blank' alt='".$row['url']."' class='kblink'>More...</a><br /><br /></div>";
    }
    $html .= "</div>";
    }
    $html .= "<div id='gallerypaginatebottom' class='paginationstyle'><a href='#' rel='previous' id='previous_page'><<&#160;&#160;Prev</a> <span class='flatview'></span><a href='#' rel='next' id='next_page'>Next&#160;&#160;>></a></div>";
    $objResponse->assign("divRows","innerHTML",$rowcount);
    $objResponse->assign("divDisplay","innerHTML",$html);
    $objResponse->script("var gallery=new virtualpaginate('virtualpage', 1); gallery.buildpagination('gallerypaginatetop');");
    return $objResponse;
    }

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    It's probably easier just to see the rendered page. Please post a link to the page on your site that contains the problematic script so we can check it out.
    DD Admin

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    CM Tech (08-09-2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Virtual Pagination with PHP5 - Test Site

    ddadmin,
    Thank you for responding. Unfortunately, the site is located inside an intranet. I'll work on getting a temporary external sample setup for you to review. I'll follow up shortly. Thank you again!
    Dan

  5. #4
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Virtual Pagination - Issue Resolved

    ddadmin,

    Thank you for the offer to review our intranet site. I was able to resolve the issue prior to getting the example on an external site for you. The issue was an unnecessary "=" character in my "for" statement. I hate it when that happens. The script works great and I am grateful for the hard work put into this forum and the developers script.

    Below is a modified version of the script that I haev worked into an Xajax implementation. It works nicely and was not difficult to implement.

    Thanks again,
    Dan


    Working and final Xajax version of the Virtual Pagination script:
    $xajax->register(XAJAX_FUNCTION, 'dataInitiate');
    function dataInitiate(){
    $objResponse = new myXajaxResponse();
    $rowsPerPage = "10";
    $total_kbs = mysql_query("SELECT * FROM ca_kb_master");
    $total = mysql_num_rows($total_kbs);
    $total_pages = ceil($total/$rowsPerPage);
    for($i=0;$i<$total_pages;$i++){
    $start = $i * $rowsPerPage;
    $kbs = mysql_query("SELECT * FROM ca_kb_master ORDER BY title LIMIT $start, $rowsPerPage");
    $html .= "<div class='virtualpage'>";
    while($row = mysql_fetch_array ($kbs))
    {
    $html .= "<br /><strong><a href='".$row['url']."' target='_blank' class='datatitlelink'>".$row['title']."</a></strong><br />".$row['description']."<br /><a href='".$row['url']."' target='_blank' alt='".$row['url']."' class='kblink'>".substr($row['url'], 0, 75)."</a><br /><a href='".$row['url']."' target='_blank' alt='".$row['url']."' class='kblink'>More...</a><br /><br />";
    }
    $html .= "</div>";
    }
    $html .= "<div id='gallerypaginate' class='paginationstyle'><a href='#' rel='previous' id='previous_page'><•&#160;&#160;Prev</a> <span class='flatview'></span><a href='#' rel='next' id='next_page'>Next&#160;&#160;•></a></div>";
    $rowcount = "<center>The search found <strong>".$total."</strong> article(s) which are displayed on <strong>".$total_pages."</strong> pages below.</center>";
    $objResponse->assign("divRows","innerHTML",$rowcount);
    $objResponse->assign("divDisplay","innerHTML",$html);
    $objResponse->script("var gallery=new virtualpaginate('virtualpage', 1); gallery.buildpagination('gallerypaginate');");
    return $objResponse;
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •