Jump to content

[SOLVED] How to display random html pages using php


Deoctor

Recommended Posts

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>";

?>

 

:confused:

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>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.