how to relate images to article id

I am creating a website using php and mysql in which I want to save part of images’ name as article id.

Eg: image_[$articleID]_1.jpg

Currently I am taking the article id as “querying the last id from article table and adding one to it”.

I want to know whether this is a right way to do it, because I am giving the article id to images before inserting the actual article to database.

In the worst case scenario I am wondering that what will happen if 10 users are inserting an article at the same time.

Does anyone of you know a proper logic to accomplish this or am I doing the right thing?

Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.