Create Divs according to database entries

Asked

Viewed 128 times

1

Good morning, I am developing a website and 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 of a blog, the last content presents first, but for that I need each content to have its own div. How can I do this? It’s the first time I work with contents from a database to a website created from scratch.

  • How you are looking up database entries??

1 answer

2


if you have an array to be returned from the bd, just foreach it into a php file (your view), like:

<?php foreach ($registos as $registo) { ?>
//isto ja é html
<div>
    <?php echo $registo['texto']; ?>
</div>
<?php } ?>
 ...
  • In this case I have several information in the database, including a link to use in an iframe. Do I use several queries for this purpose? And how do I use CSS on different Ivs? Use the same class for all?

Browser other questions tagged

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