Current location: Hot Scripts Forums » Programming Languages » PHP » Image display based on URL


Image display based on URL

Reply
  #1 (permalink)  
Old 09-09-04, 07:26 AM
rjwebgraphix rjwebgraphix is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Question Image display based on URL

I'd like to display an image based on the url in a similar fashion that you can display html files based on the address bar.

Example:

http://www.anysite.com/frameset.php?page=home

Then breaking the PHP down to it's simplest form in page frameset.php I have the following code.

<?php
include("$page.html");
?>

in the same respect I would like to change an image in frameset.php based on the url, so it would look something like this.

http://www.anysite.com/frameset.php?...picture=mypic1

I can do this by creating a separate html, adding the pic there, then using the same as the above to display that html, but for anything above a few images, it's kinda redundant. I figure the images are already there and I shouldn't need a separate html file for each image I want to display, so looking looking for it's simplest form to pass the variable to the IMG tag.

Thanks,
RJ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-09-04, 07:42 AM
rjwebgraphix rjwebgraphix is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
As an afterthought....

Can I use something like this?

<IMG SRC="<?php $picture ?>.jpg" WIDTH="100" HEIGHT="38" BORDER="0">
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-09-04, 07:52 AM
rjwebgraphix rjwebgraphix is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by rjwebgraphix
As an afterthought....

Can I use something like this?

<IMG SRC="<?php $picture ?>.jpg" WIDTH="100" HEIGHT="38" BORDER="0">
Ok, so I am talking to myself here, bear with me.

No, that doesn't work, but I'm hoping in it's simplest form I'm not too far off there.

Thanks for any help,
RJ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-09-04, 08:03 AM
rjwebgraphix rjwebgraphix is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
I tried this also....

<IMG SRC=<?php include("$picture.jpg"); ?> WIDTH="100" HEIGHT="38" BORDER="0">

which obviously didn't work, I didn't think it would, but I get the following error.

Warning: Unexpected character in input: '' (ASCII=29) state=1 in rjwebgraphix.com/forum/wb2.jpg on line 91

Parse error: parse error in rjwebgraphix.com/forum/wb2.jpg on line 91
BORDER="0">

wb2 is what I passed from the url. I think I got this error because it was expecting text like in an html and not expecting an image.

Again, any input would be helpful.

RJ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-09-04, 08:50 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<IMG SRC="<?php echo $picture.'.jpg'?>" WIDTH="100" HEIGHT="38" BORDER="0">

# from url #
$pic = htmlspecialchars($_GET['picture']); // dont use special chars like < or δεφ in pic names
<IMG SRC="<?php echo $pic.'.jpg'?>" WIDTH="100" HEIGHT="38" BORDER="0">

Last edited by <?Wille?>; 09-09-04 at 09:05 AM. Reason: forgot the url part
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-09-04, 09:02 AM
rjwebgraphix rjwebgraphix is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by <?Wille?>
PHP Code:

<IMG SRC="<?php echo $picture.'.jpg'?>" WIDTH="100" HEIGHT="38" BORDER="0">
So simple, I knew it just had to be a matter of proper formatting.

Thanks!
RJ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you display an image in <title> ?? krmoon PHP 3 06-15-04 02:55 AM
javascript redirection based on referring URL andyinorbit2000 Script Requests 1 05-31-04 02:56 AM
Display a dynamic image Bonzo PHP 1 04-28-04 05:05 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 03:02 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.