Lancom Posted July 5, 2010 Report Share Posted July 5, 2010 jquery_pagination.js $(document).ready(function(){ //Display Loading Image function Display_Load() { $("#loading").fadeIn(900,0); $("#loading").html("<img src='bigLoader.gif' />"); } //Hide Loading Image function Hide_Load() { $("#loading").fadeOut('slow'); }; //Default Starting Page Results $("#pagination li:first").css({'color' : '#FF0084'}).css({'border' : 'none'}); Display_Load(); $("#content").load("ap/pagination_data.php?p=1", Hide_Load()); //Pagination Click $("#pagination li").click(function(){ Display_Load(); //CSS Styles $("#pagination li") .css({'border' : 'solid #dddddd 1px'}) .css({'color' : '#0063DC'}); $(this) .css({'color' : '#FF0084'}) .css({'border' : 'none'}); //Loading Data var pageNum = this.id; $("#content").load("ap/pagination_data.php?p=" + pageNum, Hide_Load()); }); }); pagination.php <script type="text/javascript" src="ap/jquery.js"></script> <script type="text/javascript" src="ap/jquery_pagination.js"></script> <a href="/videos/" class="menu"><b>Видео</b></a> <div class="dotted_hr"> </div> <div id="loading" ></div> <div id="content" ></div> <?php function pagination($count,$perpage) { echo "<ul id=\"pagination\">"; $between = 5; $pages = ceil($count/$perpage); if($pages<2) { echo ""; } $page = (empty($_GET['p']) || $_GET['p']<2) ? 1 : $_GET['p']; $first = $page >= $between+1 ? $page-$between : 1; $last = $page <= $pages-$between ? $page+$between : $pages; if($page>1) { $p.= sprintf('<a href="?p=1">«</a><a href="?p=%d">‹</a>', $page-1); } for($i=$first;$i<$last;$i++) { $p.= sprintf('<span%s><a href="?p=%d">%d</a></span>', $page==$i ? ' class="current"' : '', $i, $i); } if($page<$pages) { $p.= sprintf('<a href="?p=%d">›</a><a href="?p=%d">»</a>', $page+1, $pages); } $p.= '</ul>'; echo $p; } pagination($count,$perpage); ?> pagination_data.php <?php include('config.php'); $perpage = 2; $_LIMIT = (!empty($_GET['p']) && $_GET['p']>1)?($_GET['p']*$perpage)-$perpage:0; $_LIMIT.=", ".$perpage; $result = mysql_query("SELECT * FROM ".DB_PREFIX."videos ORDER BY id DESC LIMIT ".$_LIMIT."") or die(mysql_error()); $count = mysql_num_rows(mysql_query("SELECT * FROM ".DB_PREFIX."videos")); while($row = mysql_fetch_array($result)) { $rows = mysql_fetch_array(mysql_query("SELECT * FROM ".DB_PREFIX."videos WHERE id = ".$row['id']."")); printf(" <div class=\"video\"> <div class=\"vf\"> <div class=\"video_box\"> ".$row['name']."<br /><img src=\"http://i1.ytimg.com/vi/".$row['embed']."/default.jpg\" alt=\"".$row['name']."\"/> </div> </div> </div> "); } mysql_free_result($result); ?> </table> <style> #loading { width: 100%; position: absolute; } li { list-style: none; float: left; margin-right: 16px; padding:5px; border:solid 1px #dddddd; color:#0063DC; } li:hover { color:#FF0084; cursor: pointer; } </style> video est no nexo4et vivodit pagination po strani4no... i vivodit Warning: Division by zero in ap\pagination.php on line 12 line 12 -> $pages = ceil($count/$perpage); Quote Link to comment Share on other sites More sharing options...
briedis Posted July 5, 2010 Report Share Posted July 5, 2010 (edited) Division by zero - dalīšana ar nulli. Tātad, tajā rindiņā dalītājs ir 0. Jā, no sākumskolas vajadzētu atcerēties, ka ar nulli dalīt īsti nevar :p Edited July 5, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted July 5, 2010 Report Share Posted July 5, 2010 + no skolas vajadzeetu atcereeties arii LV valodu ^_^ Quote Link to comment Share on other sites More sharing options...
Lancom Posted July 5, 2010 Author Report Share Posted July 5, 2010 (edited) bez ajax vis strada perfekti. tas vins iskatas bez ajax <?php function pagination($count,$perpage) { echo "<ul id=\"pagination\">"; $between = 5; $pages = ceil($count/$perpage); if($pages<2) { echo ""; } $page = (empty($_GET['p']) || $_GET['p']<2) ? 1 : $_GET['p']; $first = $page >= $between+1 ? $page-$between : 1; $last = $page <= $pages-$between ? $page+$between : $pages; if($page>1) { $p.= sprintf('<a href="?p=1">«</a><a href="?p=%d">‹</a>', $page-1); } for($i=$first;$i<$last;$i++) { $p.= sprintf('<span%s><a href="?p=%d">%d</a></span>', $page==$i ? ' class="current"' : '', $i, $i); } if($page<$pages) { $p.= sprintf('<a href="?p=%d">›</a><a href="?p=%d">»</a>', $page+1, $pages); } $p.= '</ul>'; echo $p; } $perpage = 2; $_LIMIT = (!empty($_GET['p']) && $_GET['p']>1)?($_GET['p']*$perpage)-$perpage:0; $_LIMIT.=", ".$perpage; $result = mysql_query("SELECT * FROM ".DB_PREFIX."videos ORDER BY id DESC LIMIT ".$_LIMIT."") or die(mysql_error()); $count = mysql_num_rows(mysql_query("SELECT * FROM ".DB_PREFIX."videos")); while($row = mysql_fetch_array($result)) { $rows = mysql_fetch_array(mysql_query("SELECT * FROM ".DB_PREFIX."videos WHERE id = ".$row['id']."")); printf(" <div class=\"video\"> <div class=\"vf\"> <div class=\"video_box\"> ".$row['name']."<br /><img src=\"http://i1.ytimg.com/vi/".$row['embed']."/default.jpg\" alt=\"".$row['name']."\"/> </div> </div> </div> \r"); } pagination($count,$perpage); mysql_free_result($result); ?> un viņš nemet Division by zero, bet kad daļu skriptu uz 2 daļam un pievienoju ajax pagination vinš uzreiz nestrada. Tatad es ajax slikti zinu tam man vajag kurš vis pareizi uzkarstis un izlabos tur kļudas. pagination.php un pagination_data.php Edited July 5, 2010 by Lancom Quote Link to comment Share on other sites More sharing options...
spainis Posted July 5, 2010 Report Share Posted July 5, 2010 (edited) izsaucot pagination $perpage ir ievadīts kā 0 un viss Edited July 5, 2010 by spainis Quote Link to comment Share on other sites More sharing options...
briedis Posted July 5, 2010 Report Share Posted July 5, 2010 izsaucot pagination $perpage ir ievadīts kā 0 un viss Nu tak uzstādi $perpage citu vērtību, nevis 0... Quote Link to comment Share on other sites More sharing options...
Lancom Posted July 5, 2010 Author Report Share Posted July 5, 2010 (edited) tatad ka es vis samainiju nerada vair Division By Zero. Pagination.php pagination_data.php tagad vajag lai paraditos pagination bet viņš negrib paradities. var_dump($perpage); visu parbaudiju paradija int(3); Edited July 5, 2010 by Lancom Quote Link to comment Share on other sites More sharing options...
Lancom Posted July 6, 2010 Author Report Share Posted July 6, 2010 Up,Soory for double post.. 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.