P
P
Petro Boyko2018-04-26 22:24:01
PHP
Petro Boyko, 2018-04-26 22:24:01

How to display data page by page?

Hello everyone, tell me how to display $size $count $summa
in files, just lines, you need to count the lines of a separate file and display the sum of all files and the weight of the file page by page

$files = glob("../data/*.*");

$fnumber = '10';

foreach($files as $file){

$name[] = basename($file);

$size = round(filesize($file)/1024,2);

$count = count(file($file));

$summa += count(file($file));

}


$counts = count($files);

$pages = ceil($counts/$fnumber);

$page = $_GET['page'];  

if(!$page OR $page=='')  
{  
        $nav_min = 0;  
        $nav_max = $fnumber - 1;  
}else{  
        $nav_min = ($page * $fnumber) - $fnumber;  
        $nav_max = ($fnumber * $page) - 1;  
}  


# Вывод  
 for($i = $nav_min; $i <= $nav_max; $i++)

{ 
        echo $name[$i]; // выводится 

           echo $size;   //  НЕ выводится 

            echo $count;   //  НЕ выводится 

} 

            echo $summa;   //  выводится 



    # Навигация  

    for($fpr = '', $i =1; $i <= $pages; $i++)
    {
        echo $fpr=(($i == 1 || $i == $pages || abs($i-$page) < 2) ? ($i == $page ? "<b style='font-size: 14px'>[$i]</b> | " : ' <a href="?page='.$i.'">'.$i.'</a> | ') : (($fpr == ' ... ' || $fpr == '')? '' : ' ... '));
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-04-26
@webinar

echo $size;   //  НЕ выводится 
            echo $count;   //  НЕ выводится

They are displayed, but they are null. You took these variables out of thin air.
You commented out the code where they were declared:
//$count = count(file($file));   // строки
//$summa += $count;
//$size = round(filesize($file)/1024,2);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question