Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $link = mysqli_connect("localhost", "root", "", "samp");
- if($link === false){
- die("ERROR: Could not connect. " . mysqli_connect_error());
- }
- $sql = "SELECT * FROM test";
- if($result = mysqli_query($link, $sql)){
- if(mysqli_num_rows($result) > 0){
- echo "<table>";
- echo "<tr>";
- echo "<th>ID</th>";
- echo "<th>Username</th>";
- echo "</tr>";
- while($row = mysqli_fetch_array($result)){
- echo "<tr>";
- echo "<td>" . $row['id'] . "</td>";
- echo "<td>" . $row['username'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- mysqli_free_result($result);
- } else{
- echo "No records matching your query were found.";
- }
- } else{
- echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
- }
- mysqli_close($link);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement