zoo- Posted April 3, 2008 Report Share Posted April 3, 2008 (edited) Es vēlos sadalīt rakstus pa lapām.. Tikai nevaru nolasīt vajadzīgās rindas priekš attiecīgās lapas (no news.txt faila). SQL tas laikam izskatās tā: $sql = "SELECT * FROM table ORDER by id LIMIT ".$start.",".$limits; bet kā nolasīt no txt faila ? Pilns kods šeit. Edited April 3, 2008 by zoo- Link to comment Share on other sites More sharing options...
777 Posted April 3, 2008 Report Share Posted April 3, 2008 kam tad tu news glaba .txt faila, liec tos ieks db, un pec tam lieto pagination , pamekle to caur google , un bus tev prieks ja es pareizi tevi sapratu Link to comment Share on other sites More sharing options...
NiTrino Posted April 3, 2008 Report Share Posted April 3, 2008 (edited) a kurš teica ka dažreiz nevar izmantot glabāšanai failā... reku man viens vecs kods iemētājies... $articles = getArticles(); // funkcija kas ielasa masīvā saturu no txt faila $pageNum = intval (abs($_GET['p'])); $rowsPerPage = 2; $rows_c = count($articles); $pageCount = ceil ($rows_c / $rowsPerPage); if ($pageNum > $pageCount) $pageNum = $pageCount-1; $offset = $pageNum * $rowsPerPage; if ($pageCount == 0) $pageCount = 1; if (!empty($articles)) { for ($i=$offset;$i<($rowsPerPage+$offset);$i++) { $article = $articles[i]; //izvads } } Edited April 3, 2008 by NiTrino Link to comment Share on other sites More sharing options...
777 Posted April 3, 2008 Report Share Posted April 3, 2008 a kurš teica ka dažreiz nevar izmantot glabāšanai failā... neviens, vnk nesaprotu tadu ideju, glabat zinjas vai vel kaut ko .txt faila , nu logs labi ... bet nu liela apjoma informaciju ... vieglak glabat to db .. Link to comment Share on other sites More sharing options...
zoo- Posted April 3, 2008 Author Report Share Posted April 3, 2008 (edited) Paldies! if (!empty($articles)) { for ($i=$offset;$i<($rowsPerPage+$offset);$i++) { $article = $articles[i]; //izvads } Šī koda daļa ļoti palīdzēja. Tikai tur pie vajadzēja tā - [$i].. Nu beigās man sanāca šādi . Edited April 3, 2008 by zoo- Link to comment Share on other sites More sharing options...
andrisp Posted April 4, 2008 Report Share Posted April 4, 2008 777, nu varbūt cilvēkam nav iespēju izmantot db, vai arī vienkārši grib zināt, kā to var norealizēt failā ? Link to comment Share on other sites More sharing options...
NiTrino Posted April 4, 2008 Report Share Posted April 4, 2008 es jau neapgalvoju ka jaizmanto txt, protams ka tas jataisa ar datubazem, cilveks vienk gribeja zinaat kaa to izdarit ar txt, un viss. Link to comment Share on other sites More sharing options...
777 Posted April 4, 2008 Report Share Posted April 4, 2008 jap, man nav nekas pret to :) Link to comment Share on other sites More sharing options...
Recommended Posts