I have a side column on my website that displays a random image from a database record. Currently I'm using the following code to determine the image's width and if it is larger than 180, if it is, it sets the width parameter on the image tag to 180, so that the image doesn't stretch the cell. I've never used any of the GD functions before, so my question is, to prevent the images from getting grainy when they are shrunk through the HTML parameter, can I dynamically resample them with GD? I'm not entirely positive how the GD functions work, I don't know if it's possible to resample and display dynamically. Of course, if anyone has any better suggestions, I'll take a look at them too. Thanks.
<?php
$query13 = "SELECT * FROM logos ORDER BY RAND() LIMIT 1";
$result13 = mysql_query($query13);
if(!$result13){
echo'Failed to get logo information.';
}else{
$num13 = mysql_num_rows($result13);
$row13 = mysql_fetch_array($result13);
$ID13 = (stripslashes($row13[ID]));
$URL13 = (stripslashes($row13[URL]));
$NAME13 = (stripslashes($row13[NAME]));
$USER13 = (stripslashes($row13[USER]));
$image_prop = getimagesize($row13[URL]);
$width = $image_prop[0];
if($width > "180"){$usewidth = "180";}else{$usewidth = $width;};
echo'<p align="center"><img src="'.$URL13.'" width="'.$usewidth.'" border="0" alt="Random Logo"></p>';
?>