Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> Stronnicowanie problem, Problem ze zmianą tekstu
głupol
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 25.04.2006

Ostrzeżenie: (0%)
-----


<?php
$file = file("dane/newsy.txt");
if($perpage == FALSE) $perpage = 5;
if($pos == FALSE) $pos = 0;
$count = count($file);
for($i = $pos; $i < ($perpage+$pos); $i++)
{
if($i > $count-1) break;
$result = explode("|", trim($file[$i]));

echo "<li>$result[0] $result[1]\n";
}

echo "<div align=\"center\">[ ";
for($p = 0; $p < $count; $p++)
{
if(!($p % $perpage))
{
$pg = ($p/$perpage)+1;
if ($p == $pos)
{
echo "<strong>$pg</strong> ";
}
else
{
echo "<a href=\"?pos=$p\">$pg</a> ";
}
}
}
echo " ]</div>";
?>
Mam problem , tekst podzielony w txt nie zmienia się po naciśnieciu 1 2 3 (tzn nie przeskakuje do dalszej części tekstu Co jest źle (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




co to ma do php5? Przenoszę.

ps: Prosze poprawic swoj kod o bbcode
Go to the top of the page
+Quote Post
Vogel
post
Post #3





Grupa: Zarejestrowani
Postów: 402
Pomógł: 0
Dołączył: 20.01.2003

Ostrzeżenie: (0%)
-----


po pierwsze

  1. <?php
  2.  
  3. if($perpage == FALSE) $perpage = 5; // ŹLE
  4. if(!isset($perpage)) $perpage = 5; // DOBRZE
  5.  
  6. ?>


po drugie. masz wylaczone zmienne globalne (i tak ma byc) wiec musisz sprawdzac zmienne _POST i _GET


  1. <?php
  2.  
  3. if($perpage == FALSE) $perpage = 5; // ŹLE
  4.  
  5. if(!isset($_GET['perpage'])) 
  6. $perpage = 5;
  7. else
  8. $perpage = $_GET['perpage']; // DOBRZE
  9.  
  10. ?>


reszte zostawiam tobie...
Go to the top of the page
+Quote Post
głupol
post
Post #4





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 25.04.2006

Ostrzeżenie: (0%)
-----


Proszę czy mogę prosić o zmianę w tych miejscach "źle" za bardzo nie wiem co jest według Pana źle (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Drugi skrypt :: co jest źle (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)

<?php
$file = file("dane/newsy.txt");
if($perpage == FALSE) $perpage = 10;
if($pos == FALSE) $pos = 0;
$count = count($file);


for($i = $pos; $i < ($perpage+$pos); $i++)
{
if($i > $count-1) break;
$result = explode("|", trim($file[$count-$i-1]));

echo "<li>$result[0] $result[1]\n";
}

echo "<div align=\"center\">[ ";
for($p = 0; $p < $count; $p++)
{
if(!($p % $perpage))
{
$pg = ($p/$perpage)+1;
if ($p == $pos)
{
echo "<strong>$pg</strong> ";
}
else
{
echo "<a href=\"?pos=$p\">$pg</a> ";
}
}
}
echo " ]</div>";



?>

Ten post edytował głupol 28.04.2006, 15:19:31
Go to the top of the page
+Quote Post
Vogel
post
Post #5





Grupa: Zarejestrowani
Postów: 402
Pomógł: 0
Dołączył: 20.01.2003

Ostrzeżenie: (0%)
-----


ZACZNIJ UŻYWAĆ BBCODE
Go to the top of the page
+Quote Post
głupol
post
Post #6





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 25.04.2006

Ostrzeżenie: (0%)
-----


[php]<?php
$file = file("dane/newsy.txt");
if(!isset($perpage)) $perpage = 5;
if($pos == FALSE) $pos = 0;
$count = count($file);
for($i = $pos; $i < ($perpage+$pos); $i++)
{
if($i > $count-1) break;
$result = explode("|", trim($file[$i]));

echo "<li>$result[0] $result[1]\n";
}

echo "<div align=\"center\">[ ";
for($p = 0; $p < $count; $p++)
{
if(!($p % $perpage))
{
$pg = ($p/$perpage)+1;
if ($p == $pos)
{
echo "<strong>$pg</strong> ";
}
else
{
echo "<a href=\"?pos=$p\">$pg</a> ";
}
}
}
echo " ]</div>";
?>

Mam proste pytanie dlaczego tekst nie jest wczytywany w dalszej częsci po naciśnięciu łącza
Go to the top of the page
+Quote Post
Vogel
post
Post #7





Grupa: Zarejestrowani
Postów: 402
Pomógł: 0
Dołączył: 20.01.2003

Ostrzeżenie: (0%)
-----


z przykrością muszę cię poinfomrować że w ogóle nie myślisz samodzielnie. podałem ci przykład. i poprawiłeś deklarowanie $perpage, ale totalnie olałeś poprawienie $pos - zrób to analogicznie i powinno zacząć działac.

i na boga edytuj swoje posty i popraw bbcode(IMG:http://forum.php.pl/style_emoticons/default/exclamation.gif) !
Go to the top of the page
+Quote Post
głupol
post
Post #8





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 25.04.2006

Ostrzeżenie: (0%)
-----


PODDAJE SIE SAM TEGO KODU CHYBA NIE ZROBIE , POZDRAWIAM (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) ((((

Ten post edytował głupol 28.04.2006, 15:55:33
Go to the top of the page
+Quote Post
nospor
post
Post #9





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




przed poddaniem się, mogles przynajmniej bbcode poprawic. zamykam wiec by uniknąc kolejnych postów w stylu "Popraw bbcode" (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Jakbys jednak chcial pomocy z tym topiciem, to prosze podeslac komus z ekipy moderującej, poprawione posty o bbcode.

edit: vogel od zabawy w moderatora mamy moderatorów
Go to the top of the page
+Quote Post

Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.12.2025 - 16:41