Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Nie dziła dzielenie wpisów na stronie
david8213
post
Post #1





Grupa: Zarejestrowani
Postów: 308
Pomógł: 0
Dołączył: 9.12.2009

Ostrzeżenie: (10%)
X----


  1. <?
  2.  
  3. $nazwa = "data.txt";
  4. $myFile = fopen($nazwa, "r");
  5. $i=0;
  6. while(!feof($myFile)) {
  7. $myLine = fgets($myFile);
  8. $i++; }
  9. fclose($myFile);
  10. print(" <font color=black>Liczba wpisów: <b>$i</b><BR><BR>");
  11. $nazwa = "data.txt";
  12. $myFile = fopen($nazwa, "r");
  13. $k=1;
  14. $end=$st+19;
  15. while(!feof($myFile))
  16. {
  17. $myLine = fgets($myFile);
  18. if ($k>=$st)
  19. {
  20. if ($k<=$end) {
  21. print("$myLine");
  22. };
  23. };
  24. $k++;
  25. }
  26. fclose($myFile);
  27. print("<br><center><font color=black>kolejne strony ... ");
  28. $ile=floor($i/19);
  29. $ctpage=floor($st/19)+1;
  30. for ($z=0;$z<=$ile;$z++)
  31. {
  32. $y=$z+1;
  33. if ($y==$ctpage) {print ("<FONT color=#000000> $y ");}
  34. else {print ("<A HREF=\"czytaj.php?st=".($z*2)."0\"> $y </A>");}
  35. };
  36. ?>


Co jest nie tak że nie działa dzielenie wpisów po 20
Dane wczytywane są z pliku tekstowego

Ten post edytował david8213 11.03.2016, 17:18:21
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
david8213
post
Post #2





Grupa: Zarejestrowani
Postów: 308
Pomógł: 0
Dołączył: 9.12.2009

Ostrzeżenie: (10%)
X----


Powyższy kod działa.

A jeżeli mam zrobione wpisy na tablicy to powyższy kod już nie zadziała

index.php
  1. <FORM ACTION="return.php" METHOD="POST">
  2.  
  3.  
  4. Autor: &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
  5.  
  6. <INPUT NAME="autor" TYPE="TEXT" SIZE="30"><BR><BR>
  7. E-mail: &nbsp; &nbsp; &nbsp; &nbsp;
  8. <INPUT NAME="adres" TYPE="TEXT" SIZE="30" MAXLENGTH="200"><BR><BR>
  9. Treść: &nbsp; &nbsp; &nbsp; &nbsp;<BR><BR>
  10. <TEXTAREA NAME="tresc" WRAP COLS=55 ROWS=10></TEXTAREA><BR><BR> &nbsp; &nbsp; &nbsp;
  11. <INPUT TYPE=SUBMIT VALUE= " Dopisz " style="BACKGROUND-COLOR: #333333; FONT-FAMILY : Verdana; FONT-SIZE : 12; color: #FFFFFF"> &nbsp; &nbsp; &nbsp;
  12. <INPUT TYPE="RESET" VALUE=" Wyczyść " style="BACKGROUND-COLOR: #333333; FONT-FAMILY : Verdana; FONT-SIZE : 12; color: #FFFFFF">
  13. </FORM></DIV>


  1. <?php
  2. $file = file("data.txt");
  3. foreach($file as $value) {
  4. $exp = explode("|",$value);
  5. echo "<center>";
  6.  
  7. echo "<table width=700><tr><td bgcolor=#C0C0C0><b><a href=mailto:$exp[1]> <i>$exp[0]</a></td><td bgcolor=#C0C0C0><div align=right><i><b>".date("d.m.Y")."<b> - ".date("H:i")."<tr><td colspan=2 bgcolor=#C0C0C0><div style=\"margin-left:5\" style=\"margin-right:5\"><font color=black><b>$exp[2]</td></tr></table><br>";
  8. echo "</center>";
  9. }
  10. ?>



wtedy plik data.txt wygląda tak :
  1. 11111111111111|222222222222|3333333333 \n
  2.  
  3. aaaaaaaaaaaaaa|bbbbbbbbbbbb|ccccccccccc \n
  4.  
  5. eeeeeeeeeeeeee|fffffffffffffffffffff|gggggggggg \n
  6.  
  7. hhhhhhhhhhhhhh|yyyyyyyyyyyy|jjjjjjjjjjjjjjjjjj \n
  8.  
  9. tttttttttttttttttttttttt|jjjjjjjjjjjjjjjjjjjjj|mmmmmmm \n


Ten post edytował david8213 19.03.2016, 15:18:42
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 18:31