Klokjis Posted August 8, 2005 Report Share Posted August 8, 2005 ideja taada, ka peec koda tiek nolasiita MySQL db un atteeloti visi ieraxti ar checkboxu iespeeju izdzeest iekjekseetos. PS.: ja $pec = '?pid veertiiba' <form action='fails.php' method='post'> <table width='740' border='1' cellpadding='5' cellspacing='0'> <tr> <td><? echo $table_desc; ?></td> <td><a href='?pid=vards'>Vārds</a></td> <td><a href='?pid=uzvards'>Uzvārds</a></td> </tr> <?php $query = "SELECT $prim_key, $pec, $vards, $uzvards, FROM $table ORDER BY $pec ASC"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { echo "\t\t\t<tr>"; echo "<td><input type='checkbox' name='deleted_items[]' value='".$row[$prim_key]."' /></td>"; echo '<td>'.$row[$vards].'</td>'; echo '<td>'.$row[$uzvards].'</td>'; echo "</tr>\n"; } ?> </table> <input type='submit' name='submit' value='Dzēst'><input type='reset' name='reser' value='Izķeksēt'> </form> un kaa vareetu sadaliit taa lai visi dati daliitos vairaakaas lapaas, nevis atteelotos vienaa garaa listaa piem.: katraa pa 20 ieraxtiem. Link to comment Share on other sites More sharing options...
Robis Posted August 8, 2005 Report Share Posted August 8, 2005 (edited) Ir jātaisa pageris. Ko tas nozīmē? Tas nozīmē, ka ir jāpadod vēl viens paremetrs '&page=1' piemēram, un atkarībā kura lapa, tik daudz iezīmē no db, apmēram, šādi: // 1. lapai querijs būs šāds $query = "SELECT $prim_key, $pec, $vards, $uzvards, FROM $table ORDER BY $pec ASC LIMIT 0,20"; // attiecīgi, ja būs 2 lapa tad querijs izskatīsies šādi: $query = "SELECT $prim_key, $pec, $vards, $uzvards, FROM $table ORDER BY $pec ASC LIMIT 19,20"; // 3. lapa $query = "SELECT $prim_key, $pec, $vards, $uzvards, FROM $table ORDER BY $pec ASC LIMIT 39,20"; Kā to realizēt to var izdomāt, bet pamatbūtība ir tāda. LIMIT pirmo parametru var izdabūt šādi: if (is_numeric($_GET['page']) && $_GET['page']>0) $offset = ceil($_GET['page']) * 20 - 1; else $offset = 19; // taalaak sho mainiigo offset liek pie LIMIT pirmaa parametra LIMIT $offset, 20 Edited August 8, 2005 by Robis Link to comment Share on other sites More sharing options...
Klokjis Posted August 8, 2005 Author Report Share Posted August 8, 2005 nu un tur kaarteejo reizi nolasa cik daudz ieraxtu ir MySQLaa un sadala... a ar kaadu command var nolasiit ieraxtu skaitu...?! Link to comment Share on other sites More sharing options...
Kristabs Posted August 8, 2005 Report Share Posted August 8, 2005 nu un tur kaarteejo reizi nolasa cik daudz ieraxtu ir MySQLaa un sadala... a ar kaadu command var nolasiit ieraxtu skaitu...?! 20510[/snapback] $sql = "vaicaajums"; $rez = mysql_query($sql); $cik = mysql_num_rows($rez); Link to comment Share on other sites More sharing options...
Robis Posted August 8, 2005 Report Share Posted August 8, 2005 ar kaadu command var nolasiit ieraxtu skaitu mysql_num_rows($query_result); Link to comment Share on other sites More sharing options...
Robis Posted August 8, 2005 Report Share Posted August 8, 2005 Secība tāda: 1. vispirms uztaisi queriju un dabū rindu skaitu 2. tālāk taisi queriju ar LIMIT $offset, 20 - šie rezultāti attēlošanai 3. atrādi rezultātu un uztaisi pageri (linki ar lapu nosaukumiem pēc kārtas: 1, 2, 3, 4... Lai dabūtu kopējo lapu skaitu, tev noderēs tas 1. dabūtais rindu skaits - taču atceries, ka pēdējā lapā var būt arī 1 rinda piemēram. Link to comment Share on other sites More sharing options...
Analgiins Posted August 8, 2005 Report Share Posted August 8, 2005 izmantojiet ADODB un nechakareejaties Link to comment Share on other sites More sharing options...
bubu Posted August 8, 2005 Report Share Posted August 8, 2005 Neizmantoju ADODB un nečakarējos. Link to comment Share on other sites More sharing options...
Analgiins Posted August 8, 2005 Report Share Posted August 8, 2005 nu njez, tiiri man viedoklis: saakumaa, kad maacaas programmiereet PHP, tad izmanto visaadus shitos mysql_query, mysql_num_rows. A ja kaut ko nopietnaaku veido, tad gan vajadzeetu nu vismaz kaadu savu klasiiti darbam ar DB Link to comment Share on other sites More sharing options...
Klokjis Posted August 8, 2005 Author Report Share Posted August 8, 2005 Robi, a ja man ir dinamiski, kjipa ka to jebkuraa briidii var papildinaat par kaadiem 30 ieraxtiem... ?! tad arii taapat iznaak? Link to comment Share on other sites More sharing options...
Kristabs Posted August 8, 2005 Report Share Posted August 8, 2005 nee, mysql_num_rows noglabaa vienu veertiibu ieksh sisteemas, kur tu vinju vairaak nekad nespeej mainiit un ietekmeet, nevis gjeneree katru reizi par jaunu skaitu cik mysql kverija pieprasiijums rindas ir skaaris! Link to comment Share on other sites More sharing options...
Robis Posted August 9, 2005 Report Share Posted August 9, 2005 Robi, a ja man ir dinamiski, kjipa ka to jebkuraa briidii var papildinaat par kaadiem 30 ieraxtiem... ?! tad arii taapat iznaak? 20538[/snapback] Protams. Vienīgi palielināsies (vai samazināsies) lapu skaits. Bet kā jau teicu - lapu skaitu ģenerē dinamiski, atkarībā no total rows skaita: $result = mysql_query("SELECT $prim_key, $pec, $vards, $uzvards, FROM $table ORDER BY $pec ASC"); $num_rows = mysql_num_rows($result); $lapu skaits = ceil($num_rows/20); Link to comment Share on other sites More sharing options...
Klokjis Posted August 9, 2005 Author Report Share Posted August 9, 2005 a pienjemsim man ir iespeeja noraadiit ?pid=aaa, ?pid=bbb vai ?pid=ccc un iznaak ka page paarsleegtos attieciigi ?pid=aaa&page=1 ... a kaa man a href jaanoraada kjipa ja noraada '?page=1' tad nesaglabaajas '?pid' a man vajag taa lai kjipa vnk pievieno mainiigo 'page=...' nevis nomet nost ?pid un pievieno ?page... PS.: ceru ka saprataat... :) ja nee, tad es tochna atziistu... labs komentaars ;DDD PPS.: kaut kaads sviesc bishkjinj gadiijaas ;) :rolleyes: Link to comment Share on other sites More sharing options...
bubu Posted August 9, 2005 Report Share Posted August 9, 2005 Ar galvu jādomā, ar galvu! echo '<a href="?pid='.$_GET['pid'].'&page=4">page 4</a>'; Link to comment Share on other sites More sharing options...
Robis Posted August 9, 2005 Report Share Posted August 9, 2005 (edited) vairākus parametrus reizē tak ar ir iespējams norādīt URLā: ?parametrs1=vertiba1¶metrs2=vertiba2¶metrs3=vertiba3 ... utt. Edited August 9, 2005 by Robis Link to comment Share on other sites More sharing options...
Recommended Posts