Вот быстрый пример:
Структура базы данных
post
------
id (AUTO_INCREMENT)
title
content
post_image
------
id (AUTO_INCREMENT)
post_id (INDEX, FOREIGN KEY to post.id)
path
PHP (с использованием mysqli)
$title = mysqli_real_escape_string($_POST['title']);
$content = mysqli_real_escape_string($_POST['content']);
mysqli_query("INSERT INTO post (title, content) VALUES ('{$title}', '{$content}')");
$postId = mysqli_insert_id();
$images = [ // Here you can process images from $_FILES
"/images/post/{$postId}/image1.png",
"/images/post/{$postId}/image2.png",
];
foreach ($images as $image) {
$safePath = mysqli_real_escape_string($image);
mysqli_query("INSERT INTO post_image (post_id, path) VALUES ({$postId}, '{$safePath}')");
}