alins Posted August 24, 2005 Report Share Posted August 24, 2005 varbuut kaadam ir aizkjeeries kaads koda gabals, kas dala lapas peec shaada principa: << 1 2 3 ... 11 12 13 14 15 ... 56 57 58 >> ja ir aktivizeeta lapa saakuma daljaa vai beigaas tad tas izskataas mazliet savaadaak, bet princips taads kaa augstaak paraadiits. mozh kaadam atrodas... ja ne tad buus mazliet jaapakustina smadzene! bet kaa parasti slinkums... B) Link to comment Share on other sites More sharing options...
Kavacky Posted August 24, 2005 Report Share Posted August 24, 2005 Sāc ka kustināt. Link to comment Share on other sites More sharing options...
alins Posted August 24, 2005 Author Report Share Posted August 24, 2005 <_< tajaa topikaa toch nava nekas noderiigs, jau ieprieksh skatiijos Link to comment Share on other sites More sharing options...
Aleksandrs Posted August 24, 2005 Report Share Posted August 24, 2005 Bet visu neesi izskatijis noteikti: http://php.lv/f/index.php?showtopic=1396 Link to comment Share on other sites More sharing options...
alins Posted August 24, 2005 Author Report Share Posted August 24, 2005 vienkaarshi sadaliit pa lapaam ir elementaari... , bet man vajadziigs peec saakumaa mineetaa principa! Link to comment Share on other sites More sharing options...
Lynx Posted August 24, 2005 Report Share Posted August 24, 2005 Mans pa lapām dalīšanas skripts, pievieno vēl 2us ifus un dabūsi sev vajadzīgo rezultātu. Vispār ir efektīvāks veids kā šo pašu skriptu uzrakstīt? $offset = !isset($_GET['lpp']) ? 0 : ($_GET['lpp'] - 1) * 40; $cat = mysql_fetch_assoc(mysql_query(SELECT group_count FROM blabla WHERE blabla LIMIT '.$offset.', 40)); $pg_count = ceil($cat['group_count'] / 40); if($pg_count > 1) { echo' <table cellpadding="1" cellspacing="0"> <tr> <td class="pagecount">'.$pg_count.' Lapas</td>'; if($_GET['lpp'] > 3) { echo'<td class="page"><a href="blabla&lpp=1" title="Iet uz pirmo lapaspusi"><b>«</b></a></td>'; } if($_GET['lpp']-1 != 0) { echo '<td class="page"><a href="blabla&lpp='.($_GET['lpp'] -1).'"><b><</b></a></td>'; } for($i = $_GET['lpp']-2; $i <= $_GET['lpp']+2; $i++) { if($i > 0 && $i <= $pg_count) echo '<td class="page"><a href="blabla&lpp='.$i.'">'.($_GET['lpp'] == $i ? '<b>'.$i.'</b>' : $i ).'</a></td>'; } if($_GET['lpp']+1 <= $pg_count) { echo'<td class="page"><a href="blabla&lpp='.($_GET['lpp'] +1).'"><b>></b></a></td>'; } if($_GET['lpp'] <= $pg_count - 3){ echo'<td class="page"><a href="blabla&lpp='.$pg_count.'" title="Iet uz pēdējo lapaspusi"><b>»</b></a></td><td></td>'; } echo' </tr> </table>'; } Rezultāts šāds: Link to comment Share on other sites More sharing options...
alins Posted August 24, 2005 Author Report Share Posted August 24, 2005 nu shitas jau izskataas labaak B) , no riita ar svaigaaku galvu meegjinaashu izmantot... paldies Link to comment Share on other sites More sharing options...
Analgiins Posted August 25, 2005 Report Share Posted August 25, 2005 btw, ja gribi paarbaudiit vai $_GET mainiigais patieshaam ir izveidots (tur ir kaut kaads cipars), tad labaak to dariit ar if(empty(...)) nevis if(!isset(...)), jo var buut taads gadiijums, kad GET mainiigais tiek padots, bet vinjsh ir tuksh - www.lapa.lv/index.php?lpp= POST mainiigais buus izveidots tieshaam tikai tad, kad tur kaut kaada veertiiba buss un te gan pietiek ar isset() Link to comment Share on other sites More sharing options...
Delfins Posted August 25, 2005 Report Share Posted August 25, 2005 POST mainiigais buus izveidots tieshaam tikai tad, kad tur kaut kaada veertiiba buss un te gan pietiek ar isset() i nifiga.. pārbaudi, pirms kaut ko tādu postē... Link to comment Share on other sites More sharing options...
Analgiins Posted August 25, 2005 Report Share Posted August 25, 2005 (edited) jaa, sorry, kljuudiijos :) Edit: nu bet anyway, buutiiba nemainaa, mainiigos paarbaudiit tikai ar isset() nepietiek, redz, ka vinji var buut tukshi, un ar tukshumiem vair kaut ko taadu "$^**&GHJ" kaut ko reekjinaat.. pashi saprotiet Edited August 25, 2005 by Analgiins Link to comment Share on other sites More sharing options...
AndzX8-842 Posted September 4, 2005 Report Share Posted September 4, 2005 (edited) Ar šādu lietu no db var dabūt rezultātus un salikt pa lapām. Pārāk grūti jau nav pārveidot, lai derētu arī kam citam. Tev tomēr nāksies kustināt "smadzeni." <?php include 'connectdb.php'; if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 20; $from = (($page * $max_results) - $max_results); $sql = mysql_query("SELECT * FROM datubāze LIMIT $from, $max_results"); while($row = mysql_fetch_array($sql)){ // Nāk visa draza ārā tieši šeit. echo "$row['db_rindas_nosaukusm_iet_šeit']"; } $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM referati"),0); $total_pages = ceil($total_results / $max_results); echo "<center>Select a Page<br />"; // "Previous" saite if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } // "Next" saite if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } echo "</center>"; ?> Edited September 4, 2005 by AndzX8-842 Link to comment Share on other sites More sharing options...
fassko Posted September 8, 2005 Report Share Posted September 8, 2005 paskaties sql manuaalii, kas ir LIMIT un OFFSET ;) Link to comment Share on other sites More sharing options...
keksuss Posted May 3, 2006 Report Share Posted May 3, 2006 Nu šitais ir pa rubli! Tiešām paldies :) Link to comment Share on other sites More sharing options...
Recommended Posts