I want to loop through each result from the mysql table and generate html div for each rows. The database table looks like following:
-------------------------------- id | color | width | img -------------------------------- 1 | red | 550 | url -------------------------------- 2 | black | 650 | url -------------------------------- I have an idea of how this might work but not sure about the syntax. Below is my attempt.
<?php // connect to the database $rows = // get rows from the db table foreach ($rows) { <div style="background-color:$color;width:$width;"> <img src="$img"> </div> }
echo();the content in the for each loop to get it to output to the screen.