ArnisR Posted July 31, 2010 Report Share Posted July 31, 2010 Kā varētu izveidot tā, lai MySQL ierakstus sadalīt vienā lapā pa 10, un spiežot "Nākamie ieraksti", esošo 10 vietā ielādētos nākamie 10. Gribētos to paveikt bez $_GET mainīgajiem un vēlams bez lapas pārlādes. Ir kādas idejas? Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted July 31, 2010 Report Share Posted July 31, 2010 http://www.9lessons.info/2009/09/pagination-with-jquery-mysql-and-php.html Quote Link to comment Share on other sites More sharing options...
sheps Posted July 31, 2010 Report Share Posted July 31, 2010 (edited) vismaz vienu get mainiigo vajadzeetu $_GET['pg'] piemērs: if(is_int($_GET['pg'])){ $pg = $_GET['pg']; }else{ $pg = 1; } $count = 156; // ierakstu skaits kopā $pagelimit = 10; //cik ieraksti vienā lapā $pgCount = ceil($count/$pagelimit ); //cik lapas kopā if($pg>$pgCount){$pg = $pgCount ;} if($pg<1){$pg = 1;} if($count>$pagelimit ){} //ja ir vairāk elementu kā ietilps vienā lapā, tad var izveidot lapu navigāciju $from = $pg * $pagelimit - $pagelimit; //kura lapa tiek ielaadeeta "SELECT * FROM tabula ORDER by id LIMIT $from,$pagelimit" Edited July 31, 2010 by sheps Quote Link to comment Share on other sites More sharing options...
ArnisR Posted August 1, 2010 Author Report Share Posted August 1, 2010 Paldies! Gan viens, gan otrs noderēja! Bet ir vispār kāds veids, lai noslēpt to $_GET mainīgo no URL'a? Quote Link to comment Share on other sites More sharing options...
Kavacky Posted August 1, 2010 Report Share Posted August 1, 2010 Un kāpēc tas būtu vajadzīgs? Kā lai es atveru tavā lapā caur linku uzreiz kaut kādu 16. lapu ar ierakstiem? Quote Link to comment Share on other sites More sharing options...
101111 Posted August 1, 2010 Report Share Posted August 1, 2010 Taisi lapošanu ar AJAX (links pirmajā atbildē). Nebūs nekas redzams adresē. Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted August 1, 2010 Report Share Posted August 1, 2010 Kaut ko vajadzētu redzēt adresē, ērtuma dēļ. Ja izmantosi tikai AJAX tad restīti galā, piemēram (#). Quote Link to comment Share on other sites More sharing options...
777 Posted August 1, 2010 Report Share Posted August 1, 2010 paginations bez refresh var veidot ar jQuery izmantojot .load() * tev jabuut vieta kur tu gribi izvadiit datus <div id="loadedContent"></div> * ciparinji kurus nospiezhot cilveks parshkirst lapu <a href="#" id="page">1</a> u.t.t * skripts, kuram tu padosi datus, kas savukart atdos tev rezultaatu. // JS kods $(function(){ $('a#page').click(function(){ var id = $('a#page').text(); / $('a#page').val(); $('#loadedContent').load('/komentari.php?='+id); } $('#loadedContent').load('/komentari.php?=1); } // PHP kods <?php // lapa automatiski viens ja nav sniegts value // limits automatiski viens, vai arii vari padot to caur js //no sakuma protams apstrada GET datus function renderComments($page=1, $limit=10) { // mysql query if($results > 0) { // izvadam araa } else { // nav komentaru } } ?> 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.