Soldato
- Joined
- 12 May 2007
- Posts
- 3,896
- Location
- Bristol
I desperately need some help. If some kind soul is bored and wouldn't mind, I'd really appreciate it.
I have the following php to drop random items in a list.
And the following html to go with it
What I want to do is have a variable in the script to determine how many list items to drop in (each one random and not a duplicate). So if I want 5 list items, I can just just change a variable in the script instead of having 5 includes in the html.
They each still have to be random and it would be nice if whichever random ones were displayed were not duplicated but that's not too important. I'll have enough variables that it shouldn't come up too often.
I have the following php to drop random items in a list.
Code:
<?php
$aHTML[0] = 'random4';
$aHTML[1] = 'random3';
$aHTML[2] = 'random2';
$aHTML[3] = 'random1';
$iUpper = sizeof($aHTML) - 1;
$iLower = 0;
$iIndex = rand($iLower, $iUpper);
echo "<li><img src='media/images/dotArrow.jpg' alt='' />$aHTML[$iIndex]</li>"
?>
And the following html to go with it
Code:
<div id="factoidsContent">
<ul>
<?php include('randomFactoids.php'); ?>
<?php include('randomFactoids.php'); ?>
<?php include('randomFactoids.php'); ?>
</ul>
</div>
What I want to do is have a variable in the script to determine how many list items to drop in (each one random and not a duplicate). So if I want 5 list items, I can just just change a variable in the script instead of having 5 includes in the html.
They each still have to be random and it would be nice if whichever random ones were displayed were not duplicated but that's not too important. I'll have enough variables that it shouldn't come up too often.