Solved

selecting and displaying images/text  from mysql

Posted on 2002-05-01
2
170 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
ID: 6984081
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
ID: 7323783
Thanks for answer - nice and clear
Haven't been to Experts Exchange in a while hence delay in respose
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

685 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