Solved

selecting and displaying images/text  from mysql

Posted on 2002-05-01
2
169 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decrypt string by php 7 47
MVC - procedural PHP 10 35
How to set the Tinymce Editor image path 4 22
SQL querys that gives me from one table into another. 2 24
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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