简体   繁体   中英

PHP & MySQL - How to add images to query result?

I am creating a car rental system for school and I was wondering how can I display the correct image of the car for each result the user gets when searching the database. For example:

A user wants to see all Toyotas in Oslo with a picture of the car in the result. The picture name is eg 'toyotaavensis.jpg'

Now what I Want is the image of the Toyota Avensis display in the div that contains the info about that specific car.

I have the images stored on my schools FTP server and I get the info from a database

I manage to get the search function working with all the info and such. I'm just stuck on the images

If you can find the image name from the DB, then you just need to add that after the PATH of the image. For eg. if the name returned from DB is: toyotaavensis.jpg and the PATH where the image is located is (related to the page on which it is to be added): images/ then you just need have the path on your page for image as: images/{DB-result-for-image}

Add a column "picture" to your database and insert the name of the associated picture everytime you add a new entity to the database. You may name the pictures for a pattern. Then, get the associated picture and display it with HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM