Hello,
I have in the DB the tables categoria
and imagens
Currently the function (in PHP) to insert in the table category is similar to this (only title itself):
public function insere($ttitulo)
{
try
{
$stmt = $this->db->prepare("INSERT INTO categoria (titulo) VALUES(:titulo)");
$stmt->bindparam(":titulo",$ttitulo);
$stmt->execute();
return true;
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}
In html, I have a form with title and possibility of insertion of up to 5 images.
The title I want to go to the category table, so far okay, the images should go to the images table, an id for each image should be created in this single submit but with inner join (or similar) that makes it possible to insert the id of the category created together with the images.
In the images table the columns look like this:
id_imagem | categoria_ID | dir_imagem
Image dir is image itself that will come from the form (I can already insert in the form the url of each image)
The question is how in a single submit insert the ids into the images table according to the amount of images in the form and the created category id, using the same form, fill the column category_ID in the images table.
The most I could try:
$stmt = $this->db->prepare("INSERT INTO categoria (titulo) VALUES(:titulo)");
$stmt = $this->db->prepare("SELECT id_imagens FROM imagens WHERE id_categoria = id_imagens ");
But it's not clear to me yet
Thank you for your help