PHP webpage & array print issue


Posted on 16th Feb 2014 07:03 pm by admin

I have this code running, and it works perfectly … however, see my bottom bit about what I see when I view source, versus what I want to see … I am having image re-sizing issues that started when I use this code. When I hard code img tags directly to the images, all works fine.

rotate.php
Code: <?php
$images=array(
"darin_1.jpg", "darin_2.jpg", "jeffb_1.jpg", "jeffb_2.jpg", "jeffb_3.jpg", "glenda_1.jpg", "glenda_2.jpg", "glenda_3.jpg", "glenda_4.jpg", "kevin_1.jpg", "kevin_2.jpg", "kevin_3.jpg", "kevin_4.jpg",
"petrina_1.jpg", "petrina_2.jpg", "mia_1.jpg", "mia_2.jpg", "dale_1.jpg", "paul_1.jpg", "raino_1.jpg", "raino_2.jpg", "raino_3.jpg", "sherri_1.jpg", "sherri_2.jpg"
);
$total=count($images);
$secondsFixed=5; // seconds to keep list the same
$seedValue=(int)(time()/$secondsFixed);
srand($seedValue);
for ($i=0;$i<$total;++$i) // shuffle list 'randomly'
{
$r=rand(0,$total-1);
$temp =$images[$i];
$images[$i]=$images[$r];
$images[$r]=$temp;
}
$index=(int)($_GET['i']); // image index passed in
$i=$index%$total; // make sure index always in bounds
$file=$images[$i];
header("Location: $file"); // and pass file reference back
?>




In my PHP page I have:
Code: <img src="profiles/images/rotate.php?i=1" alt="" border="1" width="90" height="90"/>
<img src="profiles/images/rotate.php?i=2" alt="" border="1" width="90" height="90"/>
<img src="profiles/images/rotate.php?i=3" alt="" border="1" width="90" height="90"/>
Etc ….

When I view Source, I see: (for every one of them …)
Code: <img src="profiles/images/rotate.php?i=1" alt="" border="1" width="90" height="90"/>
<img src="profiles/images/rotate.php?i=2" alt="" border="1" width="90" height="90"/>
<img src="profiles/images/rotate.php?i=3" alt="" border="1" width="90" height="90"/>
Etc….

I want to see the actual image name (darin_1.jpg for example) in the line immediately about this.
Code: <img src="profiles/images/darin_1.jpg" alt="" border="1" width="90" height="90"/>
<img src="profiles/images/darin_2.jpg" alt="" border="1" width="90" height="90"/>
<img src="profiles/images/jeffb_1.jpg" alt="" border="1" width="90" height="90"/>

How do I print the value of that array object in my <img> tag, as opposed to it displaying "rotate.php?i=1" ??

Thanks

No comments posted yet

Your Answer:

Login to answer
266 Like 17 Dislike
Previous forums Next forums
Other forums

Turning Data into URLs?
This may seem very basic to you, but I'm having a hard time figuring out how to do this since I don'

Set Categories
I am creating a submission form for somebody to come in and submit products. These products are sep

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Her

explode() function problem maybe
Hi I'm having trouble searching my database. When I type two words in the search field it only searc

Spaghetti Code
So.

I've pretty much reached the point where I have so many isset s on one page that I can't

Results from Db outputted twice
Hey guys.. for come reason my data is outputted twise shown in the image below and i cant figure out

pop3 and fsockopen
So I am able to connect to the pop3 server, log in, and check how many messages there are. I am hav

Kill a process
I have a question - how can I kill a process from a command line or by using Oracle SQL Developer? I

Warning message
I've put a website that I was doing live and I'm getting this warning message when I try to add a ne

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash