Currently I build a website, and the idea is that the index (front page) will show entries from all users as well as a main picture. I have considered the possibility that you can let users choose a primary picture when creating a topic, but I want this to happen automatically. I have also also considered that all images can be added to a database (which I will do anyway), and hinting to the specific post so that one of the images will be displayed on the front, but this will not work optimally for example, if users choose to remove a picture in the topic, but not delete it from the database.
So the question is: How can I make it possible to find the first or all images in a SQL insert, with PHP?