Jump to content

Search the Community

Showing results for tags 'pagination php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. So i have the readdir() and a while loop to loop through the contents like this <?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 $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!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.