We’d like to remind Forumites to please avoid political debate on the Forum.
This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide
HTML tag question
voodoozoe
Posts: 531 Forumite
in Techie Stuff
I am trying to display an image who's file name is taken from a database...the problem I have is every time the page loads a different image is displayed. Can I use the "img" tag but without the width and height attributes without any problems?
I have been trying to use the PHP $getimagesize function, this works if I use either the filename or the height and width attributes but not a combination of the two together.
<?PHP
list($width, $height, $type) = getimagesize($filename);
?>
<img src="<?PHP echo $filename ?>">
<img src="picture.gif", width="$width", height="$height">
either of these work but what I want to use is something like this
<img src="<?PHP echo $filename ?>" width="$width" height="$height">
Can this be done?
I have been trying to use the PHP $getimagesize function, this works if I use either the filename or the height and width attributes but not a combination of the two together.
<?PHP
list($width, $height, $type) = getimagesize($filename);
?>
<img src="<?PHP echo $filename ?>">
<img src="picture.gif", width="$width", height="$height">
either of these work but what I want to use is something like this
<img src="<?PHP echo $filename ?>" width="$width" height="$height">
Can this be done?
Laughing at my ancient signature...voodoobaby now 10 years old:eek:
0
Comments
-
Try this...
<?php
list($width, $height, $type) = getimagesize($filename);
echo "<img src='{$filename}' width='{$width}' height='{$height}'>";
?>
If you look at this line you wrote:
<img src="picture.gif", width="$width", height="$height">
You have separated your parameters with commas - HTML tag parameters don't need to be separated by commas - not sure that was anything to do with the problem.
Surely though by simply doing an IMG SRC= without any other parameters, it loads to the actual size anyway.0 -
Also, for future reference, and a more appropriate audience, i'd suggest the PHP newsgroup... http://groups.google.com/group/comp.lang.php/topics0
-
I have tried other forums (not that one though) and either get no response at all or a scathing response. My OH suggested I try on here as i was getting desperate.:o
Thanks very much for replying...and nicely too!!!Laughing at my ancient signature...voodoobaby now 10 years old:eek:0
This discussion has been closed.
Confirm your email address to Create Threads and Reply
Categories
- All Categories
- 353.5K Banking & Borrowing
- 254.1K Reduce Debt & Boost Income
- 455K Spending & Discounts
- 246.6K Work, Benefits & Business
- 602.9K Mortgages, Homes & Bills
- 178.1K Life & Family
- 260.6K Travel & Transport
- 1.5M Hobbies & Leisure
- 16K Discuss & Feedback
- 37.7K Read-Only Boards