I am trying to make a webpage that will add a card filled with data from a database if there is a row of data there. I have a <div class>
that formats the card. Is there a way to programmatically add the <div class>
so each <div class>
is a row of data?
This is the PHP I have, it does read all the rows properly:
//SQL SELECT statement
$result = $conn->prepare("SELECT userid, pName, pDesc, dDate FROM test");
$result->execute();
// assign returned array elements to variables
for($i=0; $row=$result->fetch(); $i++){
$pName = $row['pName'];
$pDesc = $row['pDesc'];
$dDate = $row['dDate'];
}
Here is the HTML, it currently only displays the last row of data:
<h1>Project Dashboard</h1>
<div class="project-container">
<label>Project Owner:</label>
<span><?php echo $pName; ?></span><br>
<label>Project Description:</label>
<span><?php echo $pDesc; ?> </span><br>
<label>Project Due Date:</label>
<span><?php echo $dDate; ?> </span><br>
<div class="progress-bar">
<div id="myBar" class="container purple" style="height:24px;width:25%">
</div>
</div>
</div>