I have never used a database (MySQL) before for my website, and I have hit a conceptual barrier as to how to load images.
- I can query the database for picture paths using AJAX, then use
<image src=/path/to/image.jpg>, but I don’t want to call both AJAX and<image> - I can use a php script like so
<image src='getImage.php'>but that leads to problems with caching as I described here
Neither of those options seems ideal to. This seems like a very basic operation since the client must make queries to the database before knowing where the file is located. I would appreciate input from more advanced programmers as to how this should be carried out.
The ‘conceptual barrier’ I have encountered, as it turns out, is the fact that I assumed I had to load the images after I loaded the page, and not during. Thanks to Mike and Squeegy, turns out the best solution would be something like