Hi Hatchet -
Your help is certainly appreciated in this Darn it, though, I must be doing something wrong as it's still not working.
I'm sure it must be something just very simple, but although I've tried to vary the code, the only thing I can get to work is if I rename the output statements like so:
[code:1:dad4063a06]
<?php include ("ad1".$s[1].".php"); ?>
[/code:1:dad4063a06]
Although that will bring up the numbers 1-5, they aren't in a randomised sequence.
If I simply leave the script with the php includes as so:
[code:1:dad4063a06]
<?php include ("ad".$s[1].".php"); ?>
[/code:1:dad4063a06]
then I simply get a page of include errors.
This is where the page is at:
http://www.britecorp-hosting5.co.uk/ads/
and this the code as it is for the moment:
[code:1:dad4063a06]
<html>
<head>
<title>Ads</title>
</head>
<body>
<script>
$s = array();
$n = 5; // the range you require (this will give 1-5)
function set_num() {
global $s, $n;
$add = "yes";
$ran = rand(1, $n);
if(count($s) > 0) {
foreach($s as $sh) {
if($ran == $sh) {
$add = "no";
}
}
}
if($add == "yes") {
$s[] = $ran;
} else {
set_num();
}
}
// call the function as needed
while(count($s) < $n) {
set_num();
}
</script>
<?php include ("ad".$s[1].".php"); ?>
<?php include ("ad".$s[2].".php"); ?>
<?php include ("ad".$s[3].".php"); ?>
<?php include ("ad".$s[4].".php"); ?>
<?php include ("ad".$s[5].".php"); ?>
</body>
</html>
[/code:1:dad4063a06]
Any ideas?
Anyway, your help is much appreciated - I'll be sure to send some links your way.
