I would like to help me solve a problem I have in my web project, my case is that I have two products registered and I want to add images to each product.
As you can see in my database I have two different images (printer.jpg and camara.jpg) but at the moment of showing the images on the website it shows me only the last saved image (camara.jpg)
This is the product of a printer but it shows me the image (camara.jpg)
And this is the product of a web camera and shows the image (camara.jpg)
What I want to know is if there is a sql statement so that in the product of the printer it shows me the image (printer.jpg) that is in my database. I leave the sql sentence I use:
$sql_last=mysqli_query($con,"select LAST_INSERT_ID(id_producto) as last from products order by id_producto desc limit 0,1");
$rw=mysqli_fetch_array($sql_last);
$id_producto=intval($rw['last']);
$sql=mysqli_query($con,"select * from products where id_producto='$id_producto' limit 0,1");
$count=mysqli_num_rows($sql);
$rw=mysqli_fetch_array($sql);
$url_image=$rw['url_image'];
I hope you help me! I do not know if I have to do a sql SELECT statement for the id. Thank you very much !!!