Ask Experts Questions for FREE Help !
Ask
    omustean's Avatar
    omustean Posts: 2, Reputation: 1
    New Member
     
    #1

    Jul 17, 2013, 11:56 AM
    How to integrate pagination system
    So I have the readdir() and a while loop to loop through the contents like this
    PHP Code:
    <?php
    $directory 
    'games';
    $row=0;
    if (
    $handle opendir($directory.'/')) {
        echo 
    '<table border="1">';
        while (
    $cat readdir($handle)) {
            if (
    $cat!='.'&&$cat!='..'&&$cat!='index.php') {
                if(
    $row==0) echo '<tr>';
                echo 
    '<td align="center"><a href="'.$directory.'/'.$cat.'" style="text-decoration:none"><img src="'.$directory.'/'.$cat.'/image.php" style="display:block" />'.str_replace('_'' '$cat).'</a></td>';    
                if(
    $row==5) {
                  echo 
    '</tr>';
                  
    $row = -1;
                }
                
    $row++;
            }
        }
        echo 
    '</table>';
    }
    ?>
    It also displays a table with a new row at every three columns of data

    The following script is a bit harder to handle for me and its like this
    PHP Code:
    $dir "/directory_name";

    // Create $files array and populate with files from $dir
    $files = array();
    //if (is_dir($dir)) {
      // if ($dh = opendir($dir)) {
          // while (($file = readdir($dh)) !== false) {
              // if($file != "." && $file != ".."){
                   
    array_push($files,$file);
                   
    //here goes the code above i think?
               // }
          // }
          // closedir($dh);
       //}
    //}

    // Set up some paging info
    $page_size=10;
    $total_pages ceil(count($files) / $page_size);

    // Get currently selected page, if not selected use 1 if too high use last page
    if(isset($_GET['p'])){
        
    $current_page $_GET['p'];
        if(
    $current_page $total_pages){
             
    $current_page $total_pages;
            }
        }
        else
        {
            
    $current_page=1;
        }

    // do some math to determine starting array index to use for the current page

    $start $current_page $page_size $page_size;


    print 
    "File Listing for $dir<br>Page $current_page of $total_pages<br><br>";

    // Print files for current page

    for($i=$start;$i<$start $page_size;$i++){
        print 
    "$files[$i]<br>";
    }

    // Print links for pages

    for($j=0;$j<$total_pages;$j++){
        
    $p $j+1;
         print 
    "<a href='index.php?p=$p'>$p</a> | ";
        } 
    I want to integrate the first script into the second if that's possible Thanks!
    omustean's Avatar
    omustean Posts: 2, Reputation: 1
    New Member
     
    #2

    Jul 19, 2013, 04:51 AM
    Any help?

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search


Check out some similar questions!

integrate e^(-(x^2))dx [ 1 Answers ]

integrate e^(-(x^2))dx

Where could I be going wrong in this Oracle PHP pagination? Table not populating [ 0 Answers ]

<?php /* Connection string to Oracle view */ /* user is patients */ /* password is patients */ $conn=oci_connect('patients','patients','192.168.1.100/hosecare'); /* Query expected to do pagination and get records */ $qry="select * from (select a.*, ROWNUM rnum ...

How can I integrate cos(x)^n where n is real? [ 6 Answers ]

How can I analytically integrate cos(x)^n where n is real, but n > 1? I know the answer when n is an integer, but the method doesn't seems to apply to real numbers. Cheers

Integrate the following [ 3 Answers ]

Last term, in my diff eq class during an exam and my professor made a mistake on one of the problems :rolleyes:. Anyway, the problem he gave us was pretty difficult to integrate. Integrate with respect to x: e^x/x Substitution and by parts didn't seem to work. The closest I got was to...

The necessity to integrate Sales and Marketing. [ 2 Answers ]

Hello everyone, greetings. Well, much information is available ditinguishing Sales and Marketing. Everyone who is acquainted with Marketing would know the Sales is a part of Marketing. There're numerous definitions available of both the concepts. I'm specifically looking for the answer of this...


View more questions Search