Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

selecting and displaying images/text  from mysql

Posted on 2002-05-01
2
Medium Priority
?
174 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 900 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

885 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