duttydea Posted March 11, 2008 Share Posted March 11, 2008 I am trying to create a HTML table that is a max of 4 cells accross & an unspecified amount down. In each of these cells there will be an image taken from a Mysql Server. The code below only shows 1 cell accross, How can i get the code to put a picture in each cell? <?php $Sql = "SELECT * FROM `prod_listing` WHERE Product_ID = '$id'"; $picresult = mysql_query($Sql); ?> <table width="30%" border="0" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF"> <?php while ($row=mysql_fetch_array($picresult)) { ?> <td height="32"><img name="" src="<?php echo $row["Product_picurl"];?>" alt=""></td> <?php } //end of loop ?> </table> thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/ Share on other sites More sharing options...
MadTechie Posted March 11, 2008 Share Posted March 11, 2008 try something like this <?php $Sql = "SELECT * FROM `prod_listing` WHERE Product_ID = '$id'"; $picresult = mysql_query($Sql); ?> <table width="30%" border="0" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF"> <?php $t = 4; $c = 4; while ($row=mysql_fetch_array($picresult)) { ?> <tr> <td height="32"><img name="" src="<?php echo $row["Product_picurl"];?>" alt=""></td> <?php if($c == 0) { $c=$t; echo "<\tr><tr>"; } $c--; } //end of loop ?> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-489084 Share on other sites More sharing options...
duttydea Posted March 11, 2008 Author Share Posted March 11, 2008 Great Stuff, Cheers for the help, i do have one other related question!! Can the iamges be resized / reporportioned? Some of the images are Hi quality, when the user clicks on it it will display thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-489104 Share on other sites More sharing options...
l0ve2hat3 Posted March 11, 2008 Share Posted March 11, 2008 yes they can! <img name="" src="<?php echo $row["Product_picurl"];?>" alt="" width="150" height="150"> Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-489110 Share on other sites More sharing options...
wmguk Posted March 11, 2008 Share Posted March 11, 2008 when the images are uploaded are they full size and hi res etc, then this script reduces the size down? if thats the case you could make a simple pop up page to display the full sized image and add an href? thats if you want a pop up? Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-489111 Share on other sites More sharing options...
l0ve2hat3 Posted March 11, 2008 Share Posted March 11, 2008 hrmmmm... i think you want this: <img name="" src="<?php echo $row["Product_picurl"];?>" alt="" width="150" height="150" onclick="window.open('<?php echo $row["Product_picurl"];?>');"> Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-489114 Share on other sites More sharing options...
duttydea Posted March 12, 2008 Author Share Posted March 12, 2008 Thanks for the help. I tried to set the image size in the script andcame across a Problem: Some of my images are different sizes and just resizing it to 150 x 150 will only mess up the pictures. Is there a script outthere that will rescale the picture on loading or willi have to resize all the pics manually? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-490624 Share on other sites More sharing options...
MadTechie Posted March 12, 2008 Share Posted March 12, 2008 try something like this <?php list($width, $height) = getimagesize($row["Product_picurl"]); $long = ($width>$height)?"Width":"Height"; ?> <img name="" src="<?php echo $row["Product_picurl"];?>" alt="" <?php echo $long="150" ?> onclick="window.open('<?php echo $row["Product_picurl"];?>');"> Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-490632 Share on other sites More sharing options...
duttydea Posted March 12, 2008 Author Share Posted March 12, 2008 Got this error: Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\test.php on line 32 32. list($width, $height) = getimagesize($row["Product_picurl"]); Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-490654 Share on other sites More sharing options...
MadTechie Posted March 12, 2008 Share Posted March 12, 2008 it timedout!!.. are the images stored on your webhost? also do you have the image file path, instead of the html path? Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-490879 Share on other sites More sharing options...
duttydea Posted March 13, 2008 Author Share Posted March 13, 2008 it timedout!!.. are the images stored on your webhost? also do you have the image file path, instead of the html path? What is the difference between the two paths? My pictures are stored on the manufacturers websites, this reduces our bandwidth but eans that the pictures come in various sizes. Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-491388 Share on other sites More sharing options...
duttydea Posted March 13, 2008 Author Share Posted March 13, 2008 seen this:http://www.sitepoint.com/article/image-resizing-php <?php function imageResize($width, $height, $target) { //takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size image if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage); //returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the return "width=\"$width\" height=\"$height\""; } ?> <?php //get the image size of the picture and load it into an array $mysock = getimagesize("images/sock001.jpg"); ?> <!-using a standard html image tag, where you would have the width and height, insert your new imageResize() function with the correct attributes --> <img src="images/sock001.jpg" <?php imageResize($mysock[0], $mysock[1], 150); ?>> how can i adapt it to get the image url from mysql? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-491431 Share on other sites More sharing options...
MadTechie Posted March 13, 2008 Share Posted March 13, 2008 the problem about using unmanaged offsite images is your can not get the size of the images unless you use getimagesize(); which timesout as it need to connect to the other sites.. i guess your need to look into a CSS solution or download the images to your site.. EDIT: oh that code won't work if mine timesout so will that code, they both relie on getimagesize() Quote Link to comment https://forums.phpfreaks.com/topic/95541-simple-php-photogallery/#findComment-491460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.