Create divs based on database entries

1

Good morning, I am developing a website and I would like to create a new div for each entry the database presented in php. I need to make a page with the same principle as a blog, the last content presents first, but for this I need each content to have its own div. How can I do this? It's the first time I've been working with content from a database for a web site created from scratch.

    
asked by anonymous 24.05.2016 / 12:29

1 answer

2

If you have an array to be returned from bd, just make a foreach inside a php file (your view), type:

<?php foreach ($registos as $registo) { ?>
//isto ja é html
<div>
    <?php echo $registo['texto']; ?>
</div>
<?php } ?>
 ...
    
24.05.2016 / 12:36