Rommeo Posted August 13, 2008 Share Posted August 13, 2008 Hi i m trying to build a website for my photo album. As i heard best way to do this is "saving photo info in mysql / uploading photo to a directory" So i did. I upload the photo and save the information of the photo in mysql. but now my problem is how can i display these photos for an order ? my table looks like ; id || place || size || number 1 usa big 1 2 usa big 2 and a photos name is like this : "usa_big_1.jpg" And I wanna display 3 big photos at the top and 3 small photos at the bottom in my page. I thought about making 2 loops like ; " img source = usa_big_$i " etc. but at that time the area for the third photo will be empty if there are 2 photos for any place. So is there any way to make a query for to display a photo that is saved in mysql ( like "display from table where photo size = big && number = 1" ?? or what is the easy way for to do this ? Should I make a query for each order ? I ll be glad if you can help. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/119508-how-can-i-display-the-photo-for-the-photo-album/ Share on other sites More sharing options...
DeanWhitehouse Posted August 13, 2008 Share Posted August 13, 2008 try $sql = query; //put ure mysql query here while($rows = mysql_fetch_assoc($sql)) { ?> <img src="<?php echo $rows['place']."_".$rows['size']."_".$rows['number'].".jpg" ?>"> <?php } Link to comment https://forums.phpfreaks.com/topic/119508-how-can-i-display-the-photo-for-the-photo-album/#findComment-615667 Share on other sites More sharing options...
JonnoTheDev Posted August 13, 2008 Share Posted August 13, 2008 Your method of storing the image data is a bit funny. Why not store the actual image filename in the database? To sort the images why not just have a sort order field in the database table? You could also store the image size in a database field using the results of getimagesize(); and then sort the images using these values. Link to comment https://forums.phpfreaks.com/topic/119508-how-can-i-display-the-photo-for-the-photo-album/#findComment-615669 Share on other sites More sharing options...
Rommeo Posted August 13, 2008 Author Share Posted August 13, 2008 Blade : But i ll use the photos in different places. Not from top to bottom.. I mean there will be some text ( data ) taken from mysql that is about the information of the place. like " photo (big ) usa is a country that is.. ( data taken from mysql ) photo( big ) for to live there ( data taken from mysql ) photo ( big ) photo(small) photo (small ) photo (small ) I think at that time, I should put quaries in while loop .. Link to comment https://forums.phpfreaks.com/topic/119508-how-can-i-display-the-photo-for-the-photo-album/#findComment-615670 Share on other sites More sharing options...
Rommeo Posted August 13, 2008 Author Share Posted August 13, 2008 Your method of storing the image data is a bit funny. Why not store the actual image filename in the database? To sort the images why not just have a sort order field in the database table? You could also store the image size in a database field using the results of getimagesize(); and then sort the images using these values. Actually the table is simplified.. There are other fields etc. And I need those fields. I just want to know how can i do this ? want to know the way how other people did that. and that size is a result of getimagesize() function. Link to comment https://forums.phpfreaks.com/topic/119508-how-can-i-display-the-photo-for-the-photo-album/#findComment-615674 Share on other sites More sharing options...
DeanWhitehouse Posted August 13, 2008 Share Posted August 13, 2008 I think by storing the image as u are is causing you alot of extra hassle , i store the whole extension e.g. image.jpg then just call that .And yes i think you will need multiple loops for the information. Link to comment https://forums.phpfreaks.com/topic/119508-how-can-i-display-the-photo-for-the-photo-album/#findComment-615681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.