1. How to set a limit for the script to display data from 20 - 40 lines per sheet?
2. Link should increase by 1
<a href="./top_100/radio_1 <a href="./top_100/radio_2 <a href="./top_100/radio_3 и т.д. (В данном случае выводит только <a href="./top_100/radio_2

 echo '<table align="left" border="0" width="100%">'; $fn = fopen("./top_100/radio.txt","r") or die("fail to open file"); while($row = fgets($fn)) { list( $sPlaylist, $sFile, $sNumber, $sArtist, $sTitle, $sCover ) = explode( "'", $row ); $sFile = substr("$sFile", 0, -2); $num = 1; $last = ++$num; echo '<tr><td width="7%"><br/><br/><div id="nau"><a href="./top_100/radio_' . $last . '/" target="_blank" id="s-nau"></a></div></td><td width="88%" align="left"><a href="./top_100/radio_' . $last . '/" target="_blank">' . $sArtist . '<br/><br/>'; echo $sCover . '<br />'; echo $sFile . '<br/><br/><div class="blue skins" id="blue-skin"> Genres: dance top 40 trance house pop </div></a></td><td width="5%"><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></td></tr>'; } echo '</table>'; fclose( $fn ); 
  • $num = 1; probably worth taking out of the loop? - vp_arth

2 answers 2

 echo '<table align="left" border="0" width="100%">'; $fn = fopen("./top_100/radio.txt","r") or die("fail to open file"); $countrow=1; $last=20; //Начальный $limit=40; //Конечный while(($row = fgets($fn)) && ($countrow<=$limit)) { //Пока есть строки и пока меньше лимита if ($last <= $countrow){//если текущий ряд больше минимального list( $sPlaylist, $sFile, $sNumber, $sArtist, $sTitle, $sCover ) = explode( "'", $row ); $sFile = substr("$sFile", 0, -2); echo '<tr><td width="7%"><br/><br/><div id="nau"><a href="./top_100/radio_' . $last . '/" target="_blank" id="s-nau"></a></div></td><td width="88%" align="left"><a href="./top_100/radio_' . $last . '/" target="_blank">' . $sArtist . '<br/><br/>'; echo $sCover . '<br />'; echo $sFile . '<br/><br/><div class="blue skins" id="blue-skin"> Genres: dance top 40 trance house pop </div></a></td><td width="5%"><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></td></tr>'; } $countrow++; } echo '</table>'; fclose( $fn ); 
  • I put: $num=20; $limit=40; $num=20; $limit=40; displays 1-21 lines. It is necessary from 20 - 40 line. And by - Link ... - please tell me. - Serg888
  • Now, I will correct it, a little differently is needed - Alexey Shatrov
  • Check, like did not miss anything - Alexey Shatrov
  • Nothing brought out. Empty page. - Serg888
  • $ countrow ++; not put there :). one more time - Alexey Shatrov

The easiest option on the knee (left your code for output left unchanged):

 $offset = 20; #сдвиг от начала $limit = 25; #количество записей для вывода $i = 0; $count = 0; while($row = fgets($fn)) { $i++; if ($i < $offset) { continue; } if ($count >= $limit){ break; } list( $sPlaylist, $sFile, $sNumber, $sArtist, $sTitle, $sCover ) = explode( "'", $row ); $sFile = substr("$sFile", 0, -2); $num = 1; $last = ++$num; echo '<tr><td width="7%"><br/><br/><div id="nau"><a href="./top_100/radio_' . $last . '/" target="_blank" id="s-nau"></a></div></td><td width="88%" align="left"><a href="./top_100/radio_' . $last . '/" target="_blank">' . $sArtist . '<br/><br/>'; echo $sCover . '<br />'; echo $sFile . '<br/><br/><div class="blue skins" id="blue-skin"> Genres: dance top 40 trance house pop </div></a></td><td width="5%"><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></td></tr>'; $count++; } 
  • Script - Nothing brought. - Serg888
  • Tell me an increase in the reference to the 1st <a href="./top_100/radio_1 - Serg888
  • @ Serg888 Opening a file for reading at the beginning of the script added? Increase can be done through a variable in a GET request. I don’t know how apache is configured - see the mod_rewrite directives. With the standard settings, you can write in the url? Page = 2 and use this number in the code as $ _GET ['page'] - Dmitry Zasypkin