Deoctor Posted November 20, 2009 Share Posted November 20, 2009 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.. <?php $dir="./clock/"; $nimg="10"; $itype="html"; $rnumb=rand(1,$nimg); echo "<a href=".$dir."clock".$rnumb.".".$itype."></a>"; ?> Link to comment https://forums.phpfreaks.com/topic/182255-solved-how-to-display-random-html-pages-using-php/ Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2009 Share Posted November 20, 2009 are your html clock1.html clock2.html ... ? or clock01.html Link to comment https://forums.phpfreaks.com/topic/182255-solved-how-to-display-random-html-pages-using-php/#findComment-961763 Share on other sites More sharing options...
Deoctor Posted November 20, 2009 Author Share Posted November 20, 2009 They are clock1.html....clock10.html Link to comment https://forums.phpfreaks.com/topic/182255-solved-how-to-display-random-html-pages-using-php/#findComment-961764 Share on other sites More sharing options...
Deoctor Posted November 20, 2009 Author Share Posted November 20, 2009 Hai i have resolved the issue myself.. after changing the code to this one. it is displaying the required one. Thank you all for your help.. <?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)); //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>"; ?> Link to comment https://forums.phpfreaks.com/topic/182255-solved-how-to-display-random-html-pages-using-php/#findComment-961803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.