Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

selecting and displaying images/text  from mysql

Posted on 2002-05-01
2
Medium Priority
?
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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‚Ķ
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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