saravanataee Posted June 5, 2013 Share Posted June 5, 2013 (edited) Dear all, I have a php page in which i have three div's. Each one has a query and set of results which i display row by row inside the div. My div3 is the one will have more records say 150 rows. So, i wanna apply pagination such that 4 records will be shown in each page. But, i would i go about applying single pagination that will be applied for all the three div's. becuz we input numbers of records returned by a query to pagination counter. But since i had three queries which one to be assiged. Might be div3 that has large records. But not sure.. Please help me on this. <?php $subcat=$_REQUEST['subcat']; include_once('inc/dbConnect.inc.php'); include_once('inc/pagination.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TopAds India</title> <link href="default.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="js/jquery.easing.1.3.js"></script> <script type="text/javascript" src="js/sprite.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("ul#nav li a").css({"opacity" : 0}).hover(function(){ $(this).stop().animate({"opacity" : 1}, 200); //Change fade-in speed }, function(){ $(this).stop().animate({"opacity" : 0}, 100);//Change fade-out speed }); }); </script> <script type="text/javascript" language="javascript" src="js/jquery.suSlider.js" ></script> <script type="text/javascript" language="javascript" > $(document).ready(function(){ loop(); function loop(){ $('#sildercontent').suSlider({ mode: 'slide', speed: 1500, select:12000, auto:true, wrapper_class: 'portfolio_container' }); } //On mouseover stop the slider $("#sildercontent").mouseover(function() { $(this).stop(); return false; }); //On mouseout start the slider $("#sildercontent").mouseout(function() { loop(); }); }); </script> </head> <body onload="changePagination('0','first')"> <div id="wrap"> <div id="header"> <table align="center" width="905px" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table align="center" width="905px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="174" valign="top" style="padding-top:10px;"><img src="images/logo.png" alt="TopAdsIndia" /></td> <td width="313" valign="top"><img src="images/logo_txt.png" alt="." width="313" height="128" /></td> <td width="418" align="right" valign="bottom" style="padding-right:0px;"><a href="post.php?post_type=1"><img src="images/post_free.png"alt="." border="0" width="168" height="53" /></a></td> </tr> </table> </td> </tr> <tr> <td> <table align="center" width="905px" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div id="page-wrap"> <div id="content"> <ul id="nav"> <li class="home"><a href="index.php">Home</a></li> <li class="aboutus"><a href="#">About Us</a></li> <li class="highlight_ads"><a href="highlighted.php">Highlight Ads</a></li> <li class="premium_ads"><a href="premium.php">Premium Ads</a></li> <li class="gallery_ads"><a href="gallery.php">Gallery Ads</a></li> <li class="contact"><a href="contact_us.php">Contact Us</a></li> </ul> </div> </div> </td> </tr> </table> </td> </tr> </table> </div> <div id="main"> <table align="center" width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="740" valign="top"><table align="left" width="740" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="740"><table align="left" width="740" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="740"> </td> </tr> <tr> <td width="740" style="padding-left:20px; padding-bottom:10px;"><h2>Premium Ad's</h2></td> </tr> <tr> <td> <div id="table1"> <?php require('config.php'); $query="select * from temp_ad_table WHERE post_type=3 AND Subcategory='$subcat'"; $result=mysql_query($query); if(mysql_num_rows($result)==0 ){ echo '<font color="red" size="5">No Post Found in this Category</font>'; }else { while($row = mysql_fetch_assoc($result)) { ?> <?php $id=$row['ad_id'];?> <div class="premium-listingpagePosts"> <div class="premium-listingpagePostsLeft"> <img src="<?php echo $row['image_location']; ?>"> </div> <div class="premium-listingpagePostsRight"> <div class="premiumslider-postsHeading"><a href="view.php?ad_id=<?php echo $id; ?>""><?php echo $row['Name'];?></a></div> <div class="premium-postsDesc"> <p> <b>Description:</b><?php echo substr(strip_tags($row['AddtionalDt']), 0, 100). "......"; ?> </p> </div> </div> <div class="premium-listingpagePostsRight2" style="vertical-align:top;"> <img src="images/Premium_Ad.png" alt="Premium Ads" border="0"> </div> </div> <div class='clear'></div> <?php } } ?> </div> </div> </div> <div id="table2"> <h2>Highlighted/Free Ad's</h2><br/> <div style="border:2px solid #343233;"> <div id="pageData2" > <?php $query1="select * from temp_ad_table"; $res1=mysql_query($query1); $count1=mysql_num_rows($res1); if($count1 > 0) { $paginationCount=getPagination($count1); } if(isset($_GET['page'])) { $pageLimit = ($_GET['page'] - 1) * 5; } else { $pageLimit = 0; } $query2="select * from temp_ad_table WHERE Subcategory='$subcat' AND (post_type=2 OR post_type=1) ORDER BY `post_type` DESC, `Date` DESC limit $pageLimit,5"; $res2=mysql_query($query2); $count2=mysql_num_rows($res2); if($count2 > 0){ while($row2=mysql_fetch_array($res2)){ $ad_id = $row2['ad_id']; $AdName=$row2['Name']; $addtitle=$row2['AddTitle']; $description=$row2['AddtionalDt']; $location=$row2['Location']; $image=$row2['image_location']; $h_ads = 'yellow'; $post_type=$row2['post_type']; if($post_type == 1) { $h_ads = 'style="background: #e8e8e8;"'; //$h_ads = '<span class='freeads-listingpagePosts'>' ; //$h_ads .= '</span>'; //$h_ads = "<span class='freeads-listingpagePosts'></span>"; } ?> <div class="highlight-listingpagePosts" <?php echo $h_ads; ?>> <div class="highlight-listingpagePostsLeft"> <img src="<?php echo $image; ?>"> </div> <div class="highlight-listingpagePostsRight"> <div class="highlight-postsHeading"> <?php if($post_type==2){?> <a href="view2.php?ad_id=<?php echo $ad_id; ?>"><?php echo $AdName; ?></a> <?php } else {?> <a href="view3.php?ad_id=<?php echo $ad_id; ?>"><?php echo $AdName; ?></a> <?php } ?> </div> <div class="highlight-postsDesc"><?php echo substr(strip_tags($row2['AddtionalDt']), 0, 100). "......"; ?></div><br/> </div><br/> </div> <div class='clear'></div> <?php }} else{ echo '<font color="red" size="5">No Post Found in this Category</font>'; } ?> </div> <?php if($count2 > 0){ ?> <div id="pag"><ul> <li class='first link' id="first"><a href="dashboard.php">First</a></li> <?php for($i=1;$i<$paginationCount+1;$i++){ ?><li class='link'><a href="?page=<?php echo $i; ?>"><?php echo $i;?></a></li><?php } ?> <li class='last link' id="last"><a href="?page=<?php echo $i-1; ?>">Last</a></li> <li class="flash"></li> </ul></div><br><br> <?php } ?> </div> </div> </td> </tr> </table> </td> </tr> </table></td> <td width="165" valign="top"><table width="165px" align="right" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> </tr> <tr><td style="padding-bottom:10px;"><h2>Gallery Ad's</h2></td></tr> <tr> <td style="background-color:#cceaee; -webkit-border-radius: 10px; -moz-border-radius: 10px;border-radius: 10px; height:900px; padding-top:10px;" valign="top"> <div id="table3"> <?php $query3="select * from temp_ad_table WHERE post_type=4 AND Subcategory='$subcat'"; $res3=mysql_query($query3); $count3=mysql_num_rows($res3); if($count3 > 0){ while($row3=mysql_fetch_array($res3)){ $ad_id = $row3['ad_id']; $AdName_gal=$row3['Name']; $addtitle_gal=$row3['AddTitle']; $description_gal=$row3['AddtionalDt']; $location_gal=$row3['Location']; $image_gal=$row3['image_location']; $post_type_gal=$row3['post_type']; ?> <div class="gallery-listingpagePosts"> <div class="gallery-listingpagePostsLeft"> <img src="<?php echo $image_gal; ?>"> </div> <div class="gallery-listingpagePostsRight"> <div class="gallery-postsHeading"> <a href="view4.php?ad_id=<?php echo $ad_id; ?>"><?php echo $AdName_gal; ?></a> </div> <div class="gallery-postsDesc"><?php echo substr(strip_tags($row3['AddtionalDt']), 0, 100). "......"; ?></div><br/> </div><br/> </div> <br/> <?php } } else{ echo'<font color="red" size="5">No Post Found in this Category</font>'; } ?> </div> </td> </tr> <tr> <td> </td> </tr> </table> </td> </tr> </table> </div> <div id="footer"><table align="center" width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="64px"><table width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td style="color:#cfcfcf;" height="64px" valign="middle"><a href="index.php" class="footlink">Home</a> | <a href="#" class="footlink">About Us</a> | <a href="highlighted.php" class="footlink">Highlighted Ads</a> | <a href="premium.php" class="footlink">Premium Ads</a> | <a href="gallery.php" class="footlink">Gallery Ads</a> | <a href="#" class="footlink">Contact Us</a></td> <td><table align="right" width="130" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="right"><a href="#"><img src="images/facebook.png" alt="Facebook" border="0" /></a></td> <td align="right"><a href="#"><img src="images/twitter.png" alt="Twitter" border="0" /></td> <td align="right"><a href="#"><img src="images/linkedin.png" alt="Linkedin" border="0" /></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td><table width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" style=" color:#828282; font-size:15px;" valign="middle" height="35px"><table width="905" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" style=" color:#828282; font-size:15px;" valign="middle">Copyright © 2013 TopAdsIndia. All rights reserved. </td> <td align="right"><a href="http://www.liveyourdreamsindia.com" target="_blank"><img src="images/designed.png" alt="Designedby: LiveYourDreamsIndia" border="0" /></a></td> </tr> </table></td> </tr> </table> </td> </tr> </table> </div> </div> </body> </html> In the above code, div id table2 has large no of records in my db. So, i have applied pagination to it. But i wanna apply same to other two div's. please help out. Edited June 5, 2013 by saravanataee Quote Link to comment Share on other sites More sharing options...
cpd Posted June 5, 2013 Share Posted June 5, 2013 You need to explain yourself better. "becuz we input numbers of records returned by a query to pagination counter" this, just makes no sense to me, along with other sentences. The impression I get is: you execute queries and get results but don't know which query will return the largest results? Yet you want to apply pagination to only one div, the one with the most data? Consider re-writing your entire OP in a new post explaining yourself much more clearly and with the relevant code, not a code dump. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.