Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

second array image values will not show

0 views
Skip to first unread message

Nosferatum

unread,
Jan 4, 2010, 7:22:45 PM1/4/10
to
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?

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 '&nbsp;&nbsp;';

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>';
}
?>

Iván Sánchez Ortega

unread,
Jan 4, 2010, 10:19:52 PM1/4/10
to
Nosferatum wrote:

> 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

Edgar Wolphe

unread,
Jan 4, 2010, 10:26:33 PM1/4/10
to
<john....@gmail.com> wrote:

How many images were you planning to show in the second part?

for ($i=0;$i<=1;$i++)

{ //etc


EW

Henrik Carlqvist

unread,
Jan 5, 2010, 2:13:15 AM1/5/10
to
Nosferatum <john....@gmail.com> wrote:
> The first part of my script works fine

> 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

Nosferatum

unread,
Jan 5, 2010, 3:23:35 AM1/5/10
to
On 5 Jan, 04:26, SpamT...@spamcop.com (Edgar Wolphe) wrote:
> EW– Skjul sitert tekst –
>
> – Vis sitert tekst –

Edgar: My goal was to show two images in the second part.

Nosferatum

unread,
Jan 5, 2010, 3:24:33 AM1/5/10
to
On 5 Jan, 08:13, Henrik Carlqvist <Henrik.Carlqv...@deadspam.com>
wrote:

Henrik, ops, I missed that one.. But, after changing it, the problem
persist.

Nosferatum

unread,
Jan 5, 2010, 3:28:14 AM1/5/10
to
On 5 Jan, 04:19, Iván Sánchez Ortega <ivansanchez-...@rroba-

Ivan, thank you. I guess I have to learn that too... :-)

0 new messages