Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: php doesn't load dynamic pagination

  1. #1
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php doesn't load dynamic pagination

    i tried to follow the directions given to me http://www.dynamicdrive.com/dynamici...nate/index.htm but nothing is being echoed from my database and all my tables and coloums are correct...not to sure if it is a ajax problem or php...but i assumed the coding only wanted me to change the php

    heres my coding



    <html>
    <head>

    <link rel="stylesheet" type="text/css" href="ajaxpagination.css" />

    <script src="ajaxpagination.js" type="text/javascript">


    </script>
    </head>

    <body>

    <ul>
    <li><a href="javascript:mybookinstance.refresh(bookonflowers)">Load Flowers Data Set (4 pages)</a></li>
    <li><a href="javascript:mybookinstance.refresh(bookonanimals)">Load Animals Data Set (3 pages)</a></li>
    <li><a href="javascript:mybookinstance.refresh(bookcombo)">Load Large Data Set (12 pages)</a> (Notice the 4 page range limit within pagination DIV)</li>
    </ul>

    <div id="paginate-top"> </div>
    <div id="bookcontent"> </div>
    <div id="paginate-bottom"> </div>

    <p><a href="javascript:mybookinstance.selectpage(1)">Select 2nd page dynamically</a></p>
    <script type="text/javascript">


    <?php
    mysql_connect("localhost", "root", "") or die(mysql_error());
    mysql_select_db("registration") or die(mysql_error());

    echo "var commentsbook={\n"; //Dynamically output javascript variable
    $commentids=mysql_query("SELECT `id` from `users`"); //get IDs to last 5 comment pages

    $idarray=array();
    while ($theid=mysql_fetch_array($commentids)){
    array_push($idarray, "'http://www.localhost.com/test/index.php?id=" . $theid[id] . "'");
    }
    echo "pages: [" . implode(",", $idarray) . "],\n"; //output: pages: [filepath1, filepath2, filepath3, etc],
    echo "selectedpage: 0\n}";

    ?>


    var comments=new ajaxpageclass.createBook(commentsbook, "bookcontent", ["paginate-top", "paginate-bottom"])
    </script>
    </body>

    </html>

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Find the below line(modified), and change it to the below.
    PHP Code:
    echo "pages: [" implode(","$idarray."],\n"//output: pages: [filepath1, filepath2, filepath3, etc], 
    I'm pretty sure that if you view the source of your page you'd find an error in the middle of the <script> tags.
    Try taking away the script tags and see what gets outputted.
    Jeremy | jfein.net

  3. #3
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i get an


    Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\test\index.php on line 44


    all ends are closing and i removed the scipt tags

    i tried what u told me

    Code:
    <?php echo "pages: [" . implode(","$idarray."],\n"; ?>
    and

    Code:
    <?php echo "pages: [" . implode(","$idarray."],\n)"; ?>
    i added the ) to close the bracket
    Last edited by contra10; 02-01-2009 at 01:30 AM. Reason: tags

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    It should be:
    Code:
    echo "pages: [" . implode(","$idarray.")],\n";
    When pasting a code, please remember to use [code] tags. That includes [ html ], [ code ], and [ php ].
    Jeremy | jfein.net

  5. #5
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i changed it but i still get the same error

    Code:
    Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\test\index.php on line 44

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Tim says:
    *You forgot a comma.
    With that, I'm guessing it should be:
    Code:
    echo "pages: [" . implode(",",$idarray) . "],\n";
    Jeremy | jfein.net

  7. #7
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    it shows this

    Code:
    var commentsbook={ pages: ['http://www.localhost.com/test/index.php?id=1','http://www.localhost.com/test/index.php?id=2'], selectedpage: 0 } var comments=new ajaxpageclass.createBook(commentsbook, "bookcontent", ["paginate-top", "paginate-bottom"])
    note there are only two users on my test

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Beautified it outputs:
    Code:
    var commentsbook={
    pages: ['http://www.localhost.com/test/index.php?id=1','http://www.localhost.com/test/index.php?id=2'], 
    selectedpage: 0
    }
    var comments=new ajaxpageclass.createBook(commentsbook, "bookcontent", ["paginate-top", "paginate-bottom"])
    Is there something wrong with that?
    Jeremy | jfein.net

  9. #9
    Join Date
    Feb 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i thought it was going to out put the users...in this case the user ids and be paginated as well...i wnated it to echo a certain amount of users and then dynamically paginate to the next page when clicked and echo more users

  10. #10
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Please post a link to the page on your site that contains the problematic script so we can check it out.


    Please do the above before I can proceed helping you.
    Jeremy | jfein.net

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
  •