Here's my php code:
Code: Select all
<?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 = $files[ rand( 0, count( $files )-1 ) ];
// Now we can include it!
include ("$file");
}
else {
print "no files found";
}
?>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!