Jump to content

Problem with creating thumbnails, brings to much from database.


inine

Recommended Posts

Greetings, i am relatively new to programming , i have been trying to create a index page for a website that would echo for me title, the text relative to it + date and time when it was posted, everything worked fine, but then i decided i wanted to include images as thumbnails as a option. I started with reworking a gallery code i had that worked great it uploaded and created thumbnails that were put in two different folders uploads and thumbnails, the thumbnail is same as ID of the post while it gets the info for the larger image from the table:photo_name in database.

 

Database is set up currently

1:ID int(30) Primary

2:photo_name varchar(200)

3 title varchar(250)

4: text(longtext)

5:date_added (datetime)

 

I managed to strip the gallery code of most of its features so it would only display the image and nothing else, so now that i removed a bunch of stuff and combined the image with my other echos it will bring every single thumbnail that is in database instead of only the one that is under a ID that includes all the text.

 

This is the code i use to retrieve the images from the database, i tried to figure out a better way to display thumbnails other than to strip down a gallery code, but seeing i am new to this i ended up getting stuck.

$sql = "SELECT  * FROM photos ORDER BY `id` DESC";$query = mysql_query($sql);while($row = mysql_fetch_array($query)){	$file = $row['photo_name'];	echo '<div id="container">  			<div id="thumbnail"><a href="uploads/'. $file .'"  title="'.'" class="thickbox"><img src="thumbnails/thumb_'.$row['id'].'.jpeg" width="282" height="158" alt="image" /></a></div>  		    <div id="info"><strong>' .'</div>		  </div>';}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...