PDA

View Full Version : php doesn't load dynamic pagination



contra10
02-01-2009, 12:50 AM
i tried to follow the directions given to me http://www.dynamicdrive.com/dynamicindex17/ajaxpaginate/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>

Nile
02-01-2009, 01:14 AM
Find the below line(modified), and change it to the below.


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.

contra10
02-01-2009, 01:29 AM
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


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

and


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

i added the ) to close the bracket

Nile
02-01-2009, 01:31 AM
It should be:


echo "pages: [" . implode(","$idarray.")],\n";


When pasting a code, please remember to use [code] tags. That includes [ html ], [ code ], and [ php ].

contra10
02-01-2009, 01:43 AM
i changed it but i still get the same error



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

Nile
02-01-2009, 01:52 AM
Tim says:
*You forgot a comma.

With that, I'm guessing it should be:


echo "pages: [" . implode(",",$idarray) . "],\n";

contra10
02-01-2009, 02:00 AM
it shows this



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

Nile
02-01-2009, 02:04 AM
Beautified it outputs:


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?

contra10
02-01-2009, 02:08 AM
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

Nile
02-01-2009, 02:10 AM
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.

contra10
02-01-2009, 02:11 AM
<?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 * from `users`"); //get IDs to last 5 comment pages

$idarray=array();
while ($theid=mysql_fetch_array($commentids)){
array_push($idarray, "'" . $theid[username] . "'");
}

echo "pages: [" . implode(",",$idarray) . "],\n"; //output: pages: [filepath1, filepath2, file
echo "selectedpage: 0\n}";

?>


that will echo the usernames but how about the pagination and limits to what is viewed on a page...thanks for the help btw

Nile
02-01-2009, 02:11 AM
Is that what you wanted?

Or do you still need help?

contra10
02-01-2009, 02:15 AM
still need help...i was trying to do this but with the username...echo 5 users then move to next page...
http://www.dynamicdrive.com/dynamicindex17/ajaxpaginate/index.htm

Nile
02-01-2009, 02:17 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

Also, can you provide all the code, including what's on index.php.

contra10
02-01-2009, 02:20 AM
sry...how do i do that...kinda new...do i just post the link and all coding... here even though im on localhost?

Nile
02-01-2009, 02:28 AM
If you on localhost, go ahead and make an account on Freehostia (http://freehostia.com/) and upload your files there. You can just post all the coding too. Use the [ php ], [ html ], or [ code ] tag.

contra10
02-01-2009, 02:32 AM
all my files ar ethere
http://localhost/test/

Nile
02-01-2009, 02:33 AM
Since your using a localhost you cannot share the link. It will simply go to my localhost. As I said before make an acount on Freehostia.

contra10
02-01-2009, 03:02 AM
the takes forever to send registration email

contra10
02-01-2009, 03:27 AM
ok i have the code working at least aalittle bit...i can echo my results inbetween the pages...thing is now how do i link my pages to the results...i changed the variables to post as this was suppose to be for post origally



<div id="paginate-top"> </div>
<div id="bookcontent">
<?php

if(is_numeric($_GET['page'])){

$page = $_GET['page'];
}

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


$da = "SELECT * FROM post_profile WHERE userid = '1' ORDER BY ppid DESC LIMIT 10";
$usposts = mysql_query($da) or die(mysql_error());

//This is where you display your query results
while($infoif = mysql_fetch_array($usposts))
{
$post= "{$infoif['post']}";
echo"$post<br>";

}

?>
FINALLY ECHOING SOMETHING</div>
<div id="paginate-bottom"> </div>


<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 `ppid` from `post_profile` LIMIT 2"); //get IDs to last 5 comment pages

$idarray=array();
while ($theid=mysql_fetch_array($commentids)){
array_push($idarray, "'" . $theid[ppid] . "'");
}
echo "pages: [" . implode(",",$idarray) . "],\n"; //output: pages: [filepath1, filepath2, file
echo "selectedpage: 0\n}";

?>



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

Nile
02-01-2009, 03:37 AM
What do you mean link the pages to the results?

Can you please be more descriptive on anything you post. It is very hard to help with no description, just a direction.

Also, can you do the following please:
Go in PHPMyAdmin -> Go in the database registration->go to export->paste the output

Thanks,
Nile

contra10
02-01-2009, 04:07 AM
Table structure for table events
Field Type Null Default
eid int(11) Yes NULL
evname varchar(30) Yes NULL
evcity varchar(20) Yes NULL
evcategory varchar(20) Yes NULL
evsubcategory varchar(20) Yes NULL
username varchar(20) Yes NULL
userid int(11) Yes NULL
continent varchar(20) Yes NULL
country varchar(20) Yes NULL
state_province varchar(35) Yes NULL
dateposted varchar(30) Yes NULL
evmail varchar(30) Yes NULL
evmonth varchar(20) Yes NULL
evday tinyint(11) Yes NULL
evyear int(11) Yes NULL
evdescription varchar(200) Yes NULL
dateofevsearch varchar(30) Yes NULL
val varchar(10) Yes NULL
hour tinyint(4) Yes NULL
minute tinyint(4) Yes NULL
hourb tinyint(4) Yes NULL
minuteb tinyint(4) Yes NULL
address varchar(25) Yes NULL
Dumping data for table events
1 Lights in the downtown area Toronto arts Acting asd 1 North America Canada Ontario A 1 2009 A12009 true 12 0 12 0
2 look into my eyes affair Toronto arts Acting asd 1 North America Canada Ontario A 1 2009 the best event ever. A12009 true 12 0 12 0
3 A party Toronto arts Acting asd 1 North America Antigua and Barbuda Barbuda D 1 2009 sdfgdsfg D12009 true 3 0 12 0
Table structure for table events_subscribers
Field Type Null Default
esid int(11) Yes NULL
userid int(11) Yes NULL
username varchar(20) Yes NULL
eventid int(11) Yes NULL
eventname varchar(30) Yes NULL
dateofpostedev varchar(15) Yes NULL
category varchar(20) Yes NULL
Dumping data for table events_subscribers
1 1 asd 1 Lights in the downtown area A12009 arts
2 1 asd 2 look into my eyes affair A12009 arts
3 1 asd 3 A party D12009 arts
Table structure for table friends
Field Type Null Default
fid int(11) Yes NULL
userid int(11) Yes NULL
username varchar(20) Yes NULL
friendid int(11) Yes NULL
friendname varchar(20) Yes NULL
Dumping data for table friends

Table structure for table friend_request
Field Type Null Default
frid int(11) Yes NULL
userid int(11) Yes NULL
username varchar(20) Yes NULL
requestid int(11) Yes NULL
requestname varchar(20) Yes NULL
value int(11) Yes NULL
Dumping data for table friend_request

Table structure for table groups
Field Type Null Default
id int(11) Yes NULL
creator varchar(80) Yes NULL
name varchar(20) Yes NULL
group varchar(20) Yes NULL
description varchar(400) Yes NULL
city varchar(20) Yes NULL
email varchar(20) Yes NULL
user varchar(80) Yes NULL
members int(11) Yes NULL
Dumping data for table groups

Table structure for table groups_users
Field Type Null Default
ugid int(11) Yes NULL
uid int(11) Yes NULL
uname varchar(80) Yes NULL
gid int(11) Yes NULL
gname varchar(80) Yes NULL
Dumping data for table groups_users

Table structure for table image
Field Type Null Default
id int(11) Yes NULL
name varchar(30) Yes NULL
type varchar(30) Yes NULL
size int(11) Yes NULL
content longblob Yes NULL
Dumping data for table image

Table structure for table inbox
Field Type Null Default
iid int(11) Yes NULL
recid int(11) Yes NULL
recusername varchar(30) Yes NULL
sendid int(11) Yes NULL
sendusername varchar(30) Yes NULL
title varchar(20) Yes NULL
message varchar(150) Yes NULL
date varchar(30) Yes NULL
value varchar(10) Yes NULL
Dumping data for table inbox

Table structure for table notes_groups
Field Type Null Default
ngid int(11) Yes NULL
gid int(11) Yes NULL
gname varchar(30) Yes NULL
uid int(11) Yes NULL
uname varchar(30) Yes NULL
notename varchar(40) Yes NULL
note varchar(600) Yes NULL
link varchar(30) Yes NULL
month varchar(15) Yes NULL
day int(11) Yes NULL
year int(11) Yes NULL
Dumping data for table notes_groups

Table structure for table pix
Field Type Null Default
pid int(11) Yes NULL
title text Yes NULL
imgdata longblob Yes NULL
Dumping data for table pix

Table structure for table post_grp
Field Type Null Default
pgid int(11) Yes NULL
grpid int(11) Yes NULL
grpname varchar(20) Yes NULL
userid int(11) Yes NULL
username varchar(20) Yes NULL
grppost varchar(300) Yes NULL
month varchar(20) Yes NULL
day int(11) Yes NULL
year int(11) Yes NULL
Dumping data for table post_grp

Table structure for table post_profile
Field Type Null Default
ppid int(11) Yes NULL
userid int(11) Yes NULL
username varchar(20) Yes NULL
postinguserid int(11) Yes NULL
postingusername varchar(20) Yes NULL
post varchar(150) Yes NULL
datepost varchar(30) Yes NULL
Dumping data for table post_profile
1 1 asd 1 asd ass January 31, 2009, 10:27 am
2 1 asd 1 asd asa January 31, 2009, 10:27 am
Table structure for table ratings
Field Type Null Default
rid int(11) Yes NULL
ratedid int(11) Yes NULL
rate tinyint(4) Yes NULL
username varchar(20) Yes NULL
Dumping data for table ratings

Table structure for table testblob
Field Type Null Default
image_id tinyint(4) Yes NULL
image_type varchar(25) Yes NULL
image longblob Yes NULL
image_size varchar(25) Yes NULL
image_ctgy varchar(25) Yes NULL
image_name varchar(50) Yes NULL
Dumping data for table testblob

Table structure for table users
Field Type Null Default
id int(11) Yes NULL
username text Yes NULL
password text Yes NULL
sex text Yes NULL
email text Yes NULL
city text Yes NULL
country text Yes NULL
month text Yes NULL
day text Yes NULL
year text Yes NULL
age int(11) Yes NULL
status varchar(50) Yes NULL
registered varchar(20) Yes NULL
image varchar(7) Yes NULL
Dumping data for table users
1 asd 7815696ecbf1c96e6894b779456d330e male Toronto Antigua and Barbuda 7 26 1985 23 doing my thing January 30, 2009, 3: false
2 qwe 76d80224611fc919a5d54f0ff9fba446 male qwe Algeria 9 26 1984 0 January 31, 2009, 6: false
Table structure for table user_should_comment
Field Type Null Default
uscid int(11) Yes NULL
userid int(11) Yes NULL
username varchar(20) Yes NULL
cuserid int(11) Yes NULL
cusername varchar(25) Yes NULL
comment varchar(30) Yes NULL
date varchar(25) Yes NULL
Dumping data for table user_should_comment

Nile
02-01-2009, 05:38 AM
That is not what the export option outputs, can you please provide the export's option output.

Thanks,
Nile