Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Dec 21, 2004, 23:00   #1
ArticleBot
SitePoint Articles
 
ArticleBot's Avatar
 
Join Date: Apr 2001
Posts: 0
Article Discussion

This is an article discussion thread for discussing the SitePoint article, "Build a PHP Multiple Picture Showcase Using PHP and HTML"
ArticleBot is offline   Reply With Quote
Old Oct 25, 2007, 04:53   #2
bluefrogx
SitePoint Zealot
 
Join Date: Oct 2007
Location: In the blogosphere
Posts: 108
You'd be handling that in HTML, this only deals with rotating the image and spitting the image out.
bluefrogx is offline   Reply With Quote
Old Oct 25, 2007, 05:09   #3
FAM99
SitePoint Member
 
Join Date: Oct 2007
Posts: 5
Correct me if im wrong but the html output will be,

<img src='mysite.com/rotate.php?i=1'>
<img src='mysite.com/rotate.php?i=2'>
<img src='mysite.com/rotate.php?i=3'>

How does the html know which picture goes to which link without tweaking the code in php, as surely you will have to pass the correct hyperlink with the image?

Thanks
FAM99 is offline   Reply With Quote
Old Apr 8, 2008, 11:00   #4
michael542
SitePoint Member
 
Join Date: Apr 2008
Posts: 3
what am I doing wrong

what am I doing wrong

I am getting the error;
Cannot modify header information - headers already sent by (output started at /home/seehereo/public_html/jengasupplementscom/2/rotate.php:9) in /home/seehereo/public_html/jengasupplementscom/2/rotate.php on line 33

example
http://jengasupplements.com.au/2/rotate.php

PHP Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
// rotate images randomly but w/o dups on same page - format:
// <img src='rotate.php?i=0'> - rotate image #0 - use 'i=1'
// for second, etc
// (c) 2004 David Pankhurst - use freely, but please leave in my credit
$images=array( // list of files to rotate - add as needed
"bomb.gif",
"frown.gif",
"grim.gif",
"smile.gif" );
$total=count($images);
$secondsFixed=10; // 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
?>



<img src='rotate.php?i=0'>image #1
<img src='rotate.php?i=1'>image #2
<img src='rotate.php?i=2'>image #3






</body>
</html>
michael542 is offline   Reply With Quote
Old Apr 8, 2008, 11:06   #5
michael542
SitePoint Member
 
Join Date: Apr 2008
Posts: 3
I figured it out...

I created a rotate.php with just the configuration php (top stuff), then created a index file with just the <img src='http://www.xx.com/rotate.php?i=0'>image #1
and it worked fine
http://jengasupplements.com.au/2/1.php
michael542 is offline   Reply With Quote
Old Apr 8, 2008, 11:45   #6
michael542
SitePoint Member
 
Join Date: Apr 2008
Posts: 3
attached is a zip file with pre made files for dummies like me
Attached Files
File Type: zip multiple-random-images-rotation-php-script.zip (14.0 KB, 15 views)
michael542 is offline   Reply With Quote
Old Oct 25, 2007, 05:22   #7
bluefrogx
SitePoint Zealot
 
Join Date: Oct 2007
Location: In the blogosphere
Posts: 108
If you really wanted to do something like that, you would the script to include the <img src> tags, something ti doesn't currently do.
bluefrogx is offline   Reply With Quote
Old Oct 25, 2007, 05:29   #8
FAM99
SitePoint Member
 
Join Date: Oct 2007
Posts: 5
Thats what i have been trying to do with,

$images=array(
"<a href='link1.html'><img src='img1.gif'></a>",
"<a href='link2.html'><img src='img2.gif'></a>",
"<a href='link3.html'><img src='img3.gif'></a>"
);

but i seem unable to output it on the page. Any suggestions where im going wrong?
FAM99 is offline   Reply With Quote
Old Oct 25, 2007, 05:34   #9
bluefrogx
SitePoint Zealot
 
Join Date: Oct 2007
Location: In the blogosphere
Posts: 108
Yep, its wrong in the sense that you're trying to adapt the script for something it wasn't meant to do making it overly complex in the process.


Refer to http://www.sitepoint.com/forums/showthread.php?t=510395 , that might fit your requirements more.
bluefrogx is offline   Reply With Quote
Old Oct 25, 2007, 05:42   #10
FAM99
SitePoint Member
 
Join Date: Oct 2007
Posts: 5
That looks just the job, will try it when i get home from work.

Thanks
FAM99 is offline   Reply With Quote
Old Apr 16, 2009, 15:24   #11
yukino_girl
SitePoint Member
 
Join Date: Apr 2009
Posts: 8
anyone have any ideas on this?
yukino_girl is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 01:36.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved