Page 1 of 1

How to display random html pages using php

Posted: Fri Nov 20, 2009 4:11 am
by ym_chaitu
Hai
I have some html files and i would like to display them in a random manner using the php.
can any one help me out..I have been trying this one..
but it is not working..

Code: Select all

<?php
$dir = "./clock/";
 
$arr_file_names = array(1=>'1.html','2.html','3.html','4.html','5.html','6.html','7.html','8.html','9.html','10.html');
 
 
 
$number_of_html_files = count($arr_file_names);
 
 
 
$rnumb = ceil(rand(1,$number_of_html_files));
 
// test the file name with its file path here -
 
//echo $dir."clock".$arr_file_names[$rnumb];
//include("$dir."clock".$arr_file_names[$rnumb]");
echo "<a href=".$dir."clock".$arr_file_names[$rnumb].">$arr_file_names[$rnumb]</a>";
 
?>
it is displaying the link,when i click the link it is going there
but i require the html file to be displayed automatically without clicking anything :banghead:

Re: How to display random html pages using php

Posted: Fri Nov 20, 2009 5:07 am
by ym_chaitu
hai all
i have resolved the issue
thank you all for the help

Code: Select all

<?php
$dir = "./clock/";
$arr_file_names = array(1=>'1.html','2.html','3.html','4.html','5.html','6.html','7.html','8.html','9.html','10.html','11.html','12.html','13.html','14.html','15.html','16.html','17.html','18.html');
$number_of_html_files = count($arr_file_names);
$rnumb = ceil(rand(1,$number_of_html_files));
//echo $dir."clock".$arr_file_names[$rnumb];
include("$dir".clock."$arr_file_names[$rnumb]");
//echo "<a href=".$dir."clock".$arr_file_names[$rnumb].">$arr_file_names[$rnumb]</a>";
?>
using this code u can randomly show up a different html file every time you refresh the page..

Re: How to display random html pages using php

Posted: Fri Nov 20, 2009 5:08 am
by ym_chaitu
hai all
i have resolved the issue
thank you all for the help

Code: Select all

<?php
$dir = "./clock/";
$arr_file_names = array(1=>'1.html','2.html','3.html','4.html','5.html','6.html','7.html','8.html','9.html','10.html','11.html','12.html','13.html','14.html','15.html','16.html','17.html','18.html');
$number_of_html_files = count($arr_file_names);
$rnumb = ceil(rand(1,$number_of_html_files));
//echo $dir."clock".$arr_file_names[$rnumb];
include("$dir".clock."$arr_file_names[$rnumb]");
//echo "<a href=".$dir."clock".$arr_file_names[$rnumb].">$arr_file_names[$rnumb]</a>";
?>
using this code u can randomly show up a different html file every time you refresh the page..