2
I’m creating a website recipes and wanted to show the image that the user entered when registering. In my database I made two tables, one from the recipe and the other for the image file.
CREATE TABLE Receita(
idReceita INT NOT NULL auto_increment,
nome_Receita VARCHAR(45) NOT NULL,
preparo TEXT NOT NULL,
ingredientes text not null,
usuario_idUsuario int,
categoria_idCategoria int,
dificuldade_idDificuldade int,
PRIMARY KEY (idReceita)
);
cREATE TABLE `arquivo` (
`id` int(11) NOT NULL,
`arquivo` varchar(200) NOT NULL,
`data` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
then I add recipe id as foreign key in the file table and when writing to the database by php use the last id function. I just don’t know how to do the list of the two tables to show the right image on my site.
<div class="col-sm-6" style="" class="img-rounded">
<?php
$sql3 = "select idreceita From Receita where nome_receita= '" . $receita . "';";
$result3 = $CONEXAO->query($sql3);
$sql_busca = "select from arquivo where receita_idreceita = '" . $result3 . "';";
$mostrar = mysqli_query($CONEXAO, $sql_busca);
$qtd_arquivos = mysqli_num_rows($mostrar);
while($dados = mysqli_fetch_array($mostrar)){
$arquivo = $dados['arquivo'];
?>
<img class="img-fluid col-md-2 img-thumbnail" src="upload/<?=$arquivo?>" width=500 height:300 />
<?php }?>
</div>
If you can help me