Jump to content


How do I paginate tabbed site with php and ajax?


4 replies to this topic

#1 Venu12

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 28 September 2009 - 02:00 PM

<?php
// database connection
require_once('./includes/base.php');

if(
$_GET['logout'] == 1){
@
$_SESSION = array();
@
session_unregister($_SESSION['userID']);
@
session_unregister($_SESSION['userName']);
@
session_unregister($_SESSION['userUser']);
@
session_unregister($_SESSION['userPass']);
@
session_destroy();
}

require(
"./templates/$template/header.php");

?>

<div id="blurb" align="right">

<script language="javascript">
function isClear()
{
document.myForm[0].value='';
return true;

}
</script>
<!-- new search -->
<?php
ob_start
();
if(!empty(
$_SESSION['userID']) and !empty($_POST['user'])){
echo
'<form action="search.php" method="post" name="myForm">
<input type="text" value="search here" id="search" size="20" name="search" onFocus="return isClear();"/>
<input type="submit" name="serachuser" value="search"/></form>'
;
}
?>
</div>
<br>
<div id="blurb" align="justify">
Hello world <?php echo "$sitename"; ?> is blah, blah, blah.......!
</div>
<br>

<div id="container-5">
<ul>
<li><a href="#fragment-13"><span>Blog</span></a></li>
<li><a href="#fragment-14"><span>Links</span></a></li>
<li><a href="#fragment-15"><span>Images</span></a></li>

</ul>
<div id="fragment-13">
<?php


$sql
= mysql_query("SELECT users.userUser, posts.postID, posts.postPost, posts.postTime, posts.postComments, userAvatar FROM users, posts WHERE users.userID = posts.postUserID ORDER BY posts.postTime DESC ");
while(
$row = mysql_fetch_array($sql)){
$abcd= $row['userName'];
$abcd = str_replace (" ", "-", $abcd);
$time = reltime($row['postTime']);

echo
'
<div class="virtualpage">
<table width="100%" >
<td width="10%" ><a href="'
.$site_url.'/'.$row['userUser'].'"><img src="'.$site_url.'/avatars/'.$row['userAvatar'].'" width="48px" height="48px" /><td width="90% "bgcolor="#F8F8F8" border=1" cellspacing="1" cellpadding="1" ><b>'.$row['postPost'].'</b><br>Posted by:&nbsp;'.$row['userUser'].',&nbsp;<a href="'.$site_url.'/blogs/'.$row['userUser'].'/'.$row['postID'].'">Comments</a>&nbsp;'.$row['postComments'].' ,&nbsp;Time elapsed:&nbsp; '.$time.'</a></td>
</table><br>

</div>'
;}




?>


div id="gallerypaginate" class="paginationstyle">
<a href="#" rel="previous">Prev</a> <span class="flatview"></span> <a href="#" rel="next">Next</a>
</div>


</div>


</div>



</div>


<div id="fragment-14">
<?php

$sql
= mysql_query("SELECT users.userUser, links.linksID, links.linksLink, links.linksPost, links.linksTime, links.linksComments,userAvatar FROM users, links WHERE users.userID = links.linksUserID ORDER BY links.linksTime DESC");
while(
$row = mysql_fetch_array($sql)){
$abcd= $row['userName'];
$abcd = str_replace (" ", "-", $abcd);
$time1 = reltime($row['linksTime']);

echo
'
<div class="virtualpage">
<table width="100%" >
<td width="10%" ><a href="'
.$site_url.'/'.$row['userUser'].'"><img src="'.$site_url.'/avatars/'.$row['userAvatar'].'" width="48px" height="48px" /><td width="90% "bgcolor="#F8F8F8" border=1" cellspacing="1" cellpadding="1" ><b>'.$row['linksPost'].'</b><br>Posted by:&nbsp;'.$row['userUser'].',&nbsp;<a href="'.$site_url.'/blogs/'.$row['userUser'].'/'.$row['linksID'].'">Comments</a>&nbsp;'.$row['linksComments'].' ,&nbsp;Time elapsed:&nbsp; '.$time1.'</a></td>
</table><br>

</div>'
;}

?>

<div id="gallerypaginate" class="paginationstyle">
<a href="#" rel="previous">Prev</a> <span class="flatview"></span> <a href="#" rel="next">Next</a>
</div>



</div>
<div id="fragment-15">
<?php
// testing
grabimages('SELECT users.userUser, images.imagesID, images.imagesFile, images.imagesPost, images.imagesTime, images.imagesComments FROM users, images WHERE users.userID = images.imagesUserID ORDER BY images.imagesTime DESC LIMIT 20');

?>

</div>
</div>








<?php

// Display footer
require("./templates/$template/footer.php");
?>

<table align="center"><tr><td align="center">
<script type="text/javascript" defer="defer">
var gallery=new virtualpaginate("virtualpage",10)
gallery.buildpagination("gallerypaginate")
</script>
</td></tr></table>
I am a self taught php programmer. So, please post the corrected code. Thanks.

Edited by Venu12, 28 September 2009 - 02:04 PM.


#2 dEcade

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 1,850 posts
  • Gender:Male
  • Location:Saskatoon, Saskatchewan
  • Interests:Guitar, Programming, Storm Chasing, Games (Designing and playing), Hockey, Photography

Posted 28 September 2009 - 05:11 PM

Would you mind describing your problem a little more? Where are you getting stuck? Is there an error?

Edited by dEcade, 28 September 2009 - 05:12 PM.


#3 Venu12

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 28 September 2009 - 05:30 PM

When I place

<div id="gallerypaginate" class="paginationstyle">
<a href="#" rel="previous">Prev</a> <span class="flatview"></span> <a href="#" rel="next">Next</a>
</div>

within <div id="fragment-13">..... </div> , the pagination shows up in fragment-14, and fragment-15 and that too incorrectly

I would like to have separate pagination for each fragments.

The main page has three tabs, namely Blogs, Links and Images. The virtual pagination works well for the first tab which is fragment-13 but I don't know how to stop showing it in fragment-14 and fragment-15.

I am using virtualpaginate.js by http://www.dynamicdrive.com

Edited by Venu12, 28 September 2009 - 05:34 PM.


#4 Venu12

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 30 September 2009 - 10:08 PM

I fixed the problem all by myself. My site www.allmicrochat.com is now running with virtual pagination in each and every tab!

Thanks anyway. Learned somenthing new as a self taught prgrammer.

#5 Neil

    Past Staff Member

  • Members
  • Pip
  • 149 posts
  • Gender:Male
  • Location:Australia

Posted 01 October 2009 - 12:20 AM

Good work on getting it all up and running. I havn't used the plugin you're using at the moment but I would recommend you try out jQuery UI tabs as well, it is quite user friendly and getting your navigation tabs and inner page tabs working is quite simple in it.

See: http://jqueryui.com/demos/

You really cannot go wrong with jquery ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users