Solved

selecting and displaying images/text  from mysql

Posted on 2002-05-01
2
166 Views
Last Modified: 2006-11-17
OK - I know this is not a difficult question for you seasoned pros but for the likes of me I am having trouble sorting out the answer.
I have a database of images and recipes that I want to show to the world. I am fine for the uploading part but am having difficulty with the displaying part!
I am going to be storing my images on the server itself and referencing the path in the mySQL db.
Here is what I want to do:
1. Extract thumbnails from the database and have them link to a larger image - possibly include extra fields to dscribe the photo. I would envision using the unique ID of the photo to do this.
2. Display recipe headers and have them link to the full text of the recipe - all from the db
What I am looking for specifically is the code that will enable me to do this.
I think the question is relatively straightforward but I am going to offer lots of points to ensure I get a good answer!
Thanks a lot
Tom
0
Comment
Question by:tomhayes
2 Comments
 
LVL 5

Accepted Solution

by:
dkjariwala earned 300 total points
Comment Utility
You can have table like,

imageid
imageurl
thumburl
keywords


So whenever someone uploads image, you first put up in some folder. Now depending upon that folder's location in your document root you can create image's url.

Say you have upload_image in htdocs folder your image url would be

http://yourserver.com/upload_image/imagename.jpg

Then you can create thumbnail, place it wherever you want. Again depending where it is stored you can create its URL and store it in DB.

Inserting keywords would be fairly easy right ???


Now displaying this information is easy, you fetch up both, thumburl and imageurl from table using appropraite keywords. Create a statement like

$query = "select thumburl,imageurl from TABLE where keywords = "%$keywords%";

$result = mysql_query($query) or die('Can not execute query.');

while($arr = mysql_fetch_array($result))
{
    $imageurl = $arr['imageurl'];
    $thumburl = $arr['thumburl'];
    print "<a href=\"$imageurl\"><img src=\"$thumburl\"></a>";
}

Thats it !!
I hope it is clear to you,
Regards,
JD






0
 

Author Comment

by:tomhayes
Comment Utility
Thanks for answer - nice and clear
Haven't been to Experts Exchange in a while hence delay in respose
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now