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?

Recommended Answers

Sorry but it was not so informative for me. I need further explanation to figure this out.

It may be me, but I found your question a little confusing. Could you elaborate further?

Jump to Post

All 3 Replies

you can limit the record

Example:
table imgs contains the following fields: imageId, articleId, imageUrl, dateUploaded
table articles contains the following fields: articleId, userId, articleContent, datePosted

select `imgurl` from `imgs` where `imgs`.`articleId` = `articles`.`articleId` limit 1

Sorry but it was not so informative for me. I need further explanation to figure this out.

Thank you anyway.

Member Avatar

Sorry but it was not so informative for me. I need further explanation to figure this out.

It may be me, but I found your question a little confusing. Could you elaborate further?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.