Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //auth for db
- $server = "localhost";
- $pass = "db4115944";
- $user = "db4115944";
- $dbn = "db4115944";
- $r = new mysqli($server, $user,$pass,$dbn);
- if ($r-> connect_error){
- die("Connection failed :".$r->connect_error);
- }
- $sql = "SELECT firstname, surname FROM nametable";
- $result = $r->query($sql);
- //prints html table with mysql element
- if ($result->num_rows > 0) {
- echo "<br><br><br>"."<table border='4' class='stats' cellspacing='0'>"."<tr>"."<th>"."First Name"."</th>"."<th>"."Surname"."</th>"."</tr>";
- while($row = $result->fetch_assoc()) {
- echo "<tr>"."<td>". $row["firstname"]."</td>"."<td>".$row["surname"]."</td>"."</tr>";
- }
- } else {
- echo "<br>"."0 results from db";
- }
- //cannot close connection as it eliminated db conn and somehow ends sessions
- //$conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement