I have a form that searches a mysql db for whatever the user is after, and returns the results on the same page in a div (using ajax then php to search mysql)…
The results are ads, as cars for example, and I want each ad to have a unique image associated with it so that it displays the images next to the ads…
Storing images in BLOBS arent really a good solution I have heard…
How would I do this the best way?
Thanx
A fast way will be to store images in a folder giving unique filenames in folder or separate folders if you want to put images of different categories in separate places. After searching the available ads, read associated unique file-names and server to client.
Suppose you save images related to car ads in folder
/images/cars/. User searches for Audi S6 and the result returns 5 ads.Now we will proceed based on the naming of the image files. If you give file related to each ad unique name and put that name into record for that ad then simply get that name and create image URL as follows:
If you are naming images based on id of ad record then use this scheme:
If you mean that at first you were sending image bytes in response, then you don’t need to do that. simply send the path constructed and use it in
srcproperty ofimgtag.PS:- My PHP skill are not very good now!