Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table border="1">
- <tr>
- <th>ID</th>
- <th>Customer Name</th>
- <th>Customer Email</th>
- <th>Date/Time</th>
- <th>Payment</th>
- </tr>
- <?php
- $conn = mysqli_connect("127.0.0.1", "root", "ascent", "world");
- $stmt = $conn->prepare("SELECT * FROM tablename");
- $stmt->execute();
- $result = $stmt->get_result();
- if($result->num_rows > 0) {
- while($rows = $result->fetch_all(MYSQLI_ASSOC)) {
- $price = array_column($rows, 'price'); // <== price is column name of the price column. So you may replace this if the name of column is not price
- $sumprice = array_sum($price);
- foreach($rows as $row) {
- echo "<tr><td>".$row['id']."</td><td>".$row['name']."</td><td>".$row['email']."</td><td>".$row['timestamp']."</td><td>".$row['payment']."</td></tr>"; // the values inside $row[] is column names. You need to replace these names with the column names you are using in your table
- }
- echo "<tr>";
- echo "<td colspan='2'>Total Gross</td>";
- echo "<td colspan='3'>".$sumprice."</td>";
- echo "</tr>";
- }
- }
- ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement