Current location: Hot Scripts Forums » Programming Languages » PHP » Insert image in php script

Insert image in php script

Reply
  #1 (permalink)  
Old
Newbie Coder
 
Join Date: Aug 2010
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Insert image in php script

I have this snippit to insert an image from a variable whithin a php page

PHP Code:

<?php


$image 
"picture2.jpg";  
Echo 
"<img src=".$image." Style=width:300px;height:240px;>"

?>
This works well but How do I add positional coordinates in the same statements. Variables would be prefered as would absolute position.

I am new to PHP and learning by many trys and failures. I would sure appreciate some help here.

Terry
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
UnrealEd's Avatar
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 27 Times in 27 Posts
Like this:
PHP Code:

<?php

$image 
"picture2.jpg";  
$width 300;
$height 280;
echo 
'<img src="'.$image.'" style=width:"' $width 'px;height:' $height 'px;">';

?>
Or this:
PHP Code:

printf('<img src="%s" style="width: %dpx; height: %dpx;" />'$image$width$height); 

Or this:
PHP Code:

echo <<<IMG
<img src="$image" style="width: {$width}px; height: {$height}px" />
IMG; 
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
The Following User Says Thank You to UnrealEd For This Useful Post:
teetwo (10-27-10)
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
Random Image Script (PHP & GD) Jleagle Script Requests 2 06-20-05 04:57 PM
PHP Image Pulling Script - Help needed! jonmainprice PHP 2 06-12-05 03:54 AM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 07:29 AM
Need help on a image slide show using php! xelanoimis PHP 2 10-16-03 06:51 PM


All times are GMT -5. The time now is 04:33 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.