The first part:
<?php
$randarray = array();
while ($i < 5)
{
unset($rand);
$rand = rand(1, 200);
if(!in_array($rand, $randarray))
{
$randarray[] = $rand;
$i++;
}
}
sort ($randarray);
for ($i=0;$i<=4;$i++){
echo '<img src="http://www.path.to/images/' . $randarray[$i] . '.png"
width="80" height="80" alt="Images part one"></img>';
}
echo ' ';
THE SECOND PART:
$randarray2 = array();
while ($i < 2)
{
unset($rand2);
$rand2 = rand(1, 50);
if(!in_array($rand2, $randarray2))
{
$randarray2[] = $rand2;
$i++;
}
}
sort ($randarray2);
for ($i=0;$i<=1;$i++){
echo '<img src="www.path.to/images/two/' . $randarray2[$i] . '.png"
width="80" height="80" alt="Images part two"></img>';
}
?>
> Sorry to bother again. The first part of my script works fine and
> return four random images, sorted by numeric value. The second part
> are supposed to do the same, but gets images from another folder, and
> fewer images. But the second part can't find the images, even they are
> there. Anyone with any idea?
What is the value of $i ?
Also, if you're doing the same task several times, you should modularize
your code (i.e. define a function and call it twice instead of copy-pasting
code).
--
----------------------------------
Iván Sánchez Ortega -ivan-sanchezortega-es-
OpenStreetMap will kill computer mapping companies the way Wikipedia killed
Encarta and encyclopedias
-- Bruce Perens
How many images were you planning to show in the second part?
for ($i=0;$i<=1;$i++)
{ //etc
EW
> But the second part can't find the images, even they are
> there. Anyone with any idea?
> The first part:
> echo '<img src="http://www.path.to/images/' . $randarray[$i] . '.png"
> THE SECOND PART:
> echo '<img src="www.path.to/images/two/' . $randarray2[$i] . '.png"
As you forgot the http:// protocol in the second part your script is
looking for a local directory named www.path.to.
regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc3(at)poolhem.se Examples of addresses which go to spammers:
root@localhost postmaster@localhost
Edgar: My goal was to show two images in the second part.
Henrik, ops, I missed that one.. But, after changing it, the problem
persist.
Ivan, thank you. I guess I have to learn that too... :-)