How To Connect Php Echo With Html Table
Có thể bạn quan tâm
how to connect php echo with html table
Get the solution ↓↓↓ I want to show mysql data in a html table... php echo shows me the content, but how can I transfer this into the html-table ? I've already added some dummy data manually into the html-table ..
<?php $sql = "SELECT id, Datum, Kunde, Menge, Produkt, Produktversion FROM Aufträge"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> ".$row["id"]. " ". $row["Datum"]. " " . $row["Kunde"] . $row["Produkt"] . $row["Produktversion"] . $row["Menge"] ."<br>"; } } else { echo "00 results"; } $conn->close(); ?> <h1>Bestellungen</h1> <div class="countdown" data-role="countdown" data-days="2"></div> <div class="container" style="padding: 25px 0px;"> <table class="table striped hovered border" data-role="datatable" data-searching="true"> <thead> <tr> <th>id.</th> <th>Datum</th> <th>Kunde</th> <th>Produkt</th> <th>Produktversion</th> <th>Menge</th> </tr> </thead> <tbody> <tr><td>2</td><td>Sonne</td><td>Forellen</td><td>50</td><td>Filet</td><td>50</td></tr> <tr><td>3</td><td>Sonne</td><td>Forellen</td><td>50</td><td>Frisch</td><td>50</td></tr> <tr><td>4</td><td>Sonne</td><td>Forellen</td><td>50</td><td>Lebend</td><td>50</td></tr> </tbody> </table> </div> Copy code Undefined asked 2022-03-25 Write your answer 610 votes
Answer
Solution:
You should iterate inside the table and add the html come in echo
<div class="container" style="padding: 25px 0px;"> <table class="table striped hovered border" data-role="datatable" data-searching="true"> <thead> <tr> <th>id.</th> <th>Datum</th> <th>Kunde</th> <th>Produkt</th> <th>Produktversion</th> <th>Menge</th> </tr> </thead> <tbody> <?php while($row = $result->fetch_assoc()) { echo "<tr> <td>".$row["id"]. "</td> <td>". $row["Datum"]. "</td> <td>". $row["Kunde"] . "</td> <td>". $row["Produkt"] . "</td> <td>". $row["Produktversion"] . "</td> <td>". $row["Menge"] ."</td> </tr>"; } ?> </tbody> </table> </div> Copy code Write your answer 174 votes
Answer
Solution:
Remeber you have to loop each to create rows for the table.
$sql = "SELECT id, Datum, Kunde, Menge, Produkt, Produktversion FROM Aufträge"; $result = $conn->query($sql); if ($result->num_rows > 0) { ?> <table> <thead> <tr> <th>id.</th> <th>Datum</th> <th>Kunde</th> <th>Produkt</th> <th>Produktversion</th> <th>Menge</th> </tr> </thead> <tbody> <?php while($row = $result->fetch_assoc()) { //echo "<br> ".$row["id"]. " ". $row["Datum"]. " " . $row["Kunde"] . $row["Produkt"] . $row["Produktversion"] . $row["Menge"] ."<br>"; ?> <td><?php echo $row["id"]; ?></td> <td><?php echo $row["Datum"] ?></td> <td><?php echo $row["Kunde"]; ?></td> <td>---</td> <td>---</td> <td>---</td> <?php } ?> </tbody> </table> <?php } else { echo "00 results"; } $conn->close(); Copy codeYou need to create each and every row inside the while loop.
Write your answerShare solution ↓
Additional Information:
Date the issue was resolved: 2022-03-25 Link To Source Link To Answer People are also looking for solutions of the problem: property [id] does not exist on this collection instance.Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Ask a QuestionSimilar questions
Find the answer in similar questions on our website.
630 php - Save data to two different tables in CakePHP 3 683 php - CDbConnection failed to open the DB connection Yii 796 PHP + SQL - Using SQL Server 'Create To' scripts to create tables through PHP 426 Is this an acceptable way to autoload html pages with php? 239 php,mysql,html - Display SQL query(conjunction) properly in HTML 374 php - Multi-tenancy - Create tables up-front or as needed? 650 Laravel php artisan shows error of JWT 234 html - PHP JSON generation problems 721 Including a html form in a php script 994 php - How to read value from HTML text input?Từ khóa » Echo Th Php
-
Echo Table In PHP - Html - Stack Overflow
-
PHP Echo And Print Statements - W3Schools
-
PHP Echo() Function - W3Schools
-
PHP Echo Statement - W3resource
-
Echo - Manual - PHP
-
How Do I Make A Table In PHP Using HTML? - Quora
-
How To Echo HTML In PHP ? - GeeksforGeeks
-
Echo Trong PHP - Hiển Thị Bảng Thông Tin Sinh Viên Bằng PHP
-
PHP Echo To Print HTML, New Line, Text And Array - Phppot
-
PHP Make Html Table Function - Gists · GitHub
-
PHP Echo And Print Statements - Tutorial Republic
-
How To Fetch Data From Database In PHP And Display In HTML Table
-
Hàm Echo() Trong PHP | Hiển Thị Dữ Liệu Văn Bản Ra Màn Hình