helps how to store image in mysql database and display it in index

Asked

Viewed 20 times

-2

I tested this code I found, is the index, in it I display products from my bank, only the image that is the same (repeats in each div) because I do not get it from the bank, I think if I took the image as I took the price and the name of the database would solve, but how can I do this, please?

<div class="container">
        <div class="row">
            <?php foreach($products as $product) : ?>
                <div class="col-4">
                    <div class="card">
                        <div class="card-body">             
                            <img src="img/produtos/buque-dia-radiante.jpg" alt="" />
                             <h4 class="card-title"><?php echo $product['nome']?></h4>
                             <h6 class="card-subtitle mb-2 text-muted">
                                R$<?php echo number_format($product['preco'], 2, ',', '.')?>
                             </h6>
                             <a class="btn btn-primary" href="carrinho.php?acao=add&id=<?php echo $product['id']?>" class="card-link">Comprar</a>
                        </div>
                    </div>
                </div>

            <?php endforeach;?>
        </div>
    </div>

1 answer

0


Good, you take a look here: https://www.devmedia.com.br/armazenando-imagens-no-mysql/32104 is an article talking about storing images in mysql.

Another alternative is to use Imgur API (https://apidocs.imgur.com/? version=Latest) , where you pass the image and they save in their database, that way, you just need to save the image ID in your bank and dps use the same API to recover the photo. Now you have to see what will give you less headache, use an API to manage your photos, or even save it..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.