View Single Post
Old 07-01-2012, 03:06 PM   PM User | #1
krispol
New Coder

 
Join Date: May 2012
Posts: 52
Thanks: 12
Thanked 0 Times in 0 Posts
krispol is an unknown quantity at this point
Randomize pages order

Hey

Here's my php code:
PHP Code:
<?php  
error_reporting 
(E_ALL E_STRICT);

$files = array();

$path "./questions/";

if( 
$handle opendir$path ) ) {
        while (
false !== ($file readdir($handle))) {
                if( 
$file != "." && $file != ".." && !is_dir$path.$file ) ) {
                                   
$files[] = $path.$file;
                                }
                }
        
// You need to populate the $files variable before you count it;)
        
$file $filesrand0count$files )-) ];
        
// Now we can include it!
        
include ("$file");
}

else {
        print 
"no files found";
}       
?>
It does what I need: randomly calls for html pages from the questions folder.

What I would need help with is:
1. How to prevent pages from repeating?
2. How to stop and redirect to some other page after all the html pages from the questions folder have been displayed?

I would appretiate any help!
krispol is offline   Reply With Quote