View Full Version : Ajax Pagination / MySql
Moonwalker
11-04-2007, 10:15 PM
1) Script Title: Ajax Pagination script
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxpaginate/index.htm
3)Describe problem:
Quote from the page with script demo
This variable can be manually defined or easily dynamically written out based on information returned from the sever, such as via PHP/ MySQL.
Where can I find this variable? I'm trying to use the Pagination script for comments from the database, but I don't know where to start.
Any help is welcome.
Thx in advance.
djr33
11-04-2007, 10:58 PM
You can check out this tutorial here:
http://www.php-mysql-tutorial.com/php-mysql-paging.php
Moonwalker
11-04-2007, 11:29 PM
Thx djr33,
I already have a backend script. I just don't know how to change the javascript variables.
Thx anyway for your help.
ddadmin
11-05-2007, 01:10 AM
It really depends on how your backend is created, there is no "plug and play" solution. But a good start would be to first read the section "Defining "settingsvar" dynamically" on the supplimentary page (http://www.dynamicdrive.com/dynamicindex17/ajaxpaginate/suppliment.htm). The general idea is to dynamically write out the "settings" portion of the script based on info from your backend, for example:
<?php
echo "<script type='text/javascript'>\n"; //Dynamically output JavaScript opening tag
echo "var mysettings={}\n"; //Dynamically output javascript variable
$commentids=mysql_query("select id from comments order by date limit 5"); //get IDs to last 5 comment pages
$idarray=array();
while ($theid=mysql_fetch_array($commentids)){
array_push($idarray, "'http://www.mysite.com/comments.php?id=" . $theid[id] . "'");
}
echo "mysettings.page=[" . implode(",", $idarray) . "]\n";
echo "mysettings.selectedpage=0\n";
echo "</script>\n"; //Dynamically output JavaScript closing tag
?>
djr33
11-05-2007, 01:21 AM
A link to your page wouldn't hurt, either.
Moonwalker
11-05-2007, 03:04 PM
Thank you ddadmin!!!
I was looking for that supplimentary page, I didn't see it yesterday. That was all I needed.
Cheers.
Edit:
Btw sorry for posting it in the wrong forum, I just realised that.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.