picture size in tables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Denisem
Forum Newbie
Posts: 20
Joined: Sat May 04, 2002 8:48 am
Location: VA

picture size in tables

Post by Denisem »

does anyone know how I set all my pics in a table to the same size? I have a form that pulls pic paths from an mysql db. The problem is the pics are different sizes. How do I make them uniform?

Thanks,
Denise
samscripts
Forum Commoner
Posts: 57
Joined: Tue Apr 23, 2002 4:34 pm
Location: London, UK

Post by samscripts »

Hi Denise,

if you just want to display the pics the same size, i think you can just specify it in the <img> tag like this:

Code: Select all

<img src="yourpicture.jpg" width="thewidthyouwantdisplayed" height="theheightetc">
or using code you posted before:

Code: Select all

echo "<img src="http://www.umuc.edu/~em680a10/" . $row&#1111;"image"] . "" border="0" width="120" height="120">";
(assuming you want the images to be 120x120)

The only problem with this is if the images are not all in proportion - some of them will end up looking squashed.

hope this helps, :) Sam
User avatar
riley
Forum Commoner
Posts: 45
Joined: Thu May 02, 2002 6:31 pm

Post by riley »

It can be a simple as this

$picpath = mysql_result($result,$i,"filename");

<IMG Border='0' Width='180' Alt='Photo' Src=$picpath>

you can also add a height component but the ratio may distort the picture.
Denisem
Forum Newbie
Posts: 20
Joined: Sat May 04, 2002 8:48 am
Location: VA

Post by Denisem »

samscripts wrote:Hi Denise,

if you just want to display the pics the same size, i think you can just specify it in the <img> tag like this:

Code: Select all

<img src="yourpicture.jpg" width="thewidthyouwantdisplayed" height="theheightetc">
or using code you posted before:

Code: Select all

echo "<img src="http://www.umuc.edu/~em680a10/" . $row&#1111;"image"] . "" border="0" width="120" height="120">";
(assuming you want the images to be 120x120)

The only problem with this is if the images are not all in proportion - some of them will end up looking squashed.

hope this helps, :) Sam

Sam - awesome - works like a charm. .....Thanks!!!
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

being the CSS fan i am here is my two bits:

make a CSS selector like this:

table img {
width: /* the size you want */
height: /* the size you want */
}

this will then be applied to every img tag contained within all tables
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

I agree with mydimensin

Post by gotDNS »

I am a huge CSS fan as well, definately go with mydimension on this one.

Also, DON'T FORGET YOUR SEMICOLENS AT THE END OF EACH PROPERTY :D .

Code: Select all

table img &#123; 
width: /* the size you want */ ;
height: /* the size you want */ ;
&#125;
Post Reply