Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con=mysqli_connect("example.com","peter","abc123","my_db");
- // Check connection
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $result = mysqli_query($con,"SELECT * FROM Persons");
- echo "<table border='1'>";
- $i = 0;
- while($row = $result->fetch_assoc())
- {
- if ($i == 0) {
- $i++;
- echo "<tr>";
- foreach ($row as $key => $value) {
- echo "<th>" . $key . "</th>";
- }
- echo "</tr>";
- }
- echo "<tr>";
- foreach ($row as $value) {
- echo "<td>" . $value . "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
- mysqli_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement