Jee Posted July 17, 2004 Report Share Posted July 17, 2004 Pienjemsim, ka man ir viesu graamata. Gribu, lai paraada pedeejos 20 ierakstus un paareejie ir apakshaa zem linkiem [20 - 40] [40 - 60] (nu pa lapaam) utt. Lai parāda pēdeejos 20 ierakstus es maaku uztaisiit, bet nemaaku uztaisiit, lai paareejie buutu zem tiem linkiem. Link to comment Share on other sites More sharing options...
Aleksejs Posted July 17, 2004 Report Share Posted July 17, 2004 The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must be integer constants. With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1): mysql> SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15 For compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax. To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last: mysql> SELECT * FROM table LIMIT 95,18446744073709551615; With one argument, the value specifies the number of rows to return from the beginning of the result set: mysql> SELECT * FROM table LIMIT 5; # Retrieve first 5 rows In other words, LIMIT n is equivalent to LIMIT 0,n. http://dev.mysql.com/doc/mysql/en/SELECT.html Link to comment Share on other sites More sharing options...
Jee Posted July 18, 2004 Author Report Share Posted July 18, 2004 Aizmirsu parteikt, ka viesugraamata ir uz txt failiem! Link to comment Share on other sites More sharing options...
bubu Posted July 18, 2004 Report Share Posted July 18, 2004 Nu vai nav vienalga, vai tā viesu grāmata ir mysql'ā vai txt failos vai word dokumentā! Tur jau tikai atšķirās metodes kā tu dabu informāciju ārā, nevis tā navigācija! Vai tad tik grūti pakustināt savas smadzenes un padomāt kā cilvēks saprot to navigāciju? Piemēram, pēc tā, ka lūk šinī lapā ieraksti sākas no 20-tā. Tātad programmai arī būtu jāmāk noteikt, ka tagad ieraksti būtu jāattēlo no 20-tā. Un kā php nodod šādus parametrus? Kautvai piemēram ar GET parametriem: <a href="mans_skripts.php?saakt_ar=20">[20 - 39]</a> Tagad atliek tikai php skriptā nolasīt to $_GET['saakt_ar'] mainīgā vērtību un lasot ierakstus no txt/sql/worda izlaist pirmos 20, un drukāt nākamos 20. A bet, ja parametrs būs 40, tad izlaist pirmos 40 un drukāt nākamos 20 (tas atbildīs gadījumam [40 - 59]. Nu vai doma tagad skaidra? Link to comment Share on other sites More sharing options...
Jee Posted July 19, 2004 Author Report Share Posted July 19, 2004 No no kura raksta velk aaraa es arii maaku uztaisiit, bet nemaaku uztaisiit liidz kuram failam vilks aaraa! Link to comment Share on other sites More sharing options...
hu_ha Posted July 19, 2004 Report Share Posted July 19, 2004 (edited) nu tu pastaasti kaa tev tie raksti tiek glabaati. Ja teksta failaa, tad pienjemu, ka tiek visi vienaa failaa (ir redzeets arii ka katrs savaa) Nu tad liekot ciklaa un lasot no faila lieto kaadu skaitiitaaju... $id=0,1,2,3... if ($id==0) $id=1; //ja nav id noraadiits, tad reekjina kaa 1 $i=$id*20; //no kura ieraksta izvadiit $j=$i+20; //liidz kuram izvadiit (tb 20 vienaa lapaa) $k=0; while (nav faila beigas && $k<=$j ) { //faila beigas vai 20 ieraksti if ($k>=$i && $k<=$j) { //raksti kas ir vajadziigajaa diapazonaa izvada uz ekraana ierakstu } $k++; } tas ir viens no variantiem. tik vajag piesliipeet un padomaat. gan jau ka var uzcept ko labaaku kaa par sho 3 minuushu domu gaajienu.. p.s. veel bik pielabojam... (varbuut veel kas atrodas kljuudains) Edited July 19, 2004 by hu_ha Link to comment Share on other sites More sharing options...
Jee Posted July 28, 2004 Author Report Share Posted July 28, 2004 Es glabaaju, katru rakstu savaa txt failaa! Izlasu shaadi! $cont = "skaits.txt"; $num = file($cont); $num[0]++; $vie = 11; $a = $num[0]; $b = "$a.txt"; $p = $num[0]-$vie; while($b > 0 ) { if($b != $a++){ $content = file("$b.txt"); while($val = each($content)){ $tmp = explode("|+|",$val[1]); $date = $tmp[0]; if ($tmp[3]==""){ $web = ""; }else{ $web="<a href=\"http://$tmp[3]\" target=\"_blank\">www</a>"; } if ($gb_flthtml) {$tmp[4] = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" target=\"_blank\">\\0</a>", $tmp[4]);} if($tmp[2]==""){ $vards=$tmp[1]; }else{ $vards="<a href=mailto:$tmp[2]>$tmp[1]</a>"; } echo "<br><table class=\"line\" align=\"center\" bgcolor=#ffffff width=98% cellspacing=0 cellpadding=0 border=\"0\"> <tr><td background=\"img/aut.jpg\">$vards $web</td></tr> <tr><td class=\"kal\" bgcolor=#f0f0f0><pre>$tmp[4]</td></tr> <tr><td><p align=\"right\" id=\"date\">$date</td></tr></table>"; } } $b = $b-1; } Link to comment Share on other sites More sharing options...
Recommended Posts