I have a homework assignment that is asking me to loop through a mysql query and display the results in a table row. I have a snippet of what the finished assignment is supposed to look like down below. And I also need to I go inside the href for the “Details” line and echo out the id of each row. I also need to “total” # of customers as the screenshot down below shows.
I have spent 20-30 minutes Googling and reading the posts on various sites to try to get some help with this assignment but have not been able to get the help I need. I guess I need someone to help me walk through the rest of this assignment. My professor works in the private sector, teaches as an adjunct professor, and has a very big family to take care of, so he is not available a lot of time.
Can someone help me with some tips, suggestions, and/or point me in the right direction?
include 'connection.php'; $query = "SELECT id, first_name, last_name FROM customers ORDER BY last_name asc"; $stmt = $db->prepare($query); $stmt->execute();
<!doctype html>Granger Customers
<div class="row" style="margin-bottom:30px"> <div class="col-xs-12"> <ul class="nav nav-pills"> <li class="nav-item"> <a class="nav-link" href="index.php">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="customers.php">Customers</a> </li> <li class="nav-item"> <a class="nav-link" href="">Search</a> </li> <li class="nav-item"> <a class="nav-link" href="">Add New</a> </li> </ul> </div> </div>
<div class="col-xs-12"> <p><strong>There are a total of XXX customers.</strong></p> <table class="table table-bordered table-striped table-hover"> <thead> <tr class="success"> <th class="text-center">#</th> <th>Customer ID</th> <th>Last Name</th> <th>First name</th> <th class="text-center">Details</th> </tr> </thead> <tbody> <!--start of row that you need to include for each item returned from the query--> <tr> <td class="text-center active">1</td> <td>20597</td> <td>Aadil</td> <td>Kareem</td> <td class="text-center"><a class="btn btn-xs btn-primary" href="details.php?id=20597">Details</a></td> </tr> </tbody> </table> </div>