<?php
$query = "SELECT * FROM Persons;";
// Run query using mysqli
$result = $mysqli->query($query);
$data = $result->fetch_assoc();
print("Efternamn: {$data['LastName']}");
print( "\n");
print($result->num_rows);
print( "\n");
print(gettype($result));
print( "\n");
print($data[0]);
print("\n");
echo '<pre>';
print_r($data);
echo '</pre>';
print( "\n");
echo "<table>";
while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results
print($row[0]);
echo "<tr><td>" . htmlspecialchars($row[0]) . "</td><td>" . htmlspecialchars($row[1]) . "</td></tr>"; //$row['index'] the index here is a field name
print( "\n");
}
echo "</table>"; //Close the table in HTML
//mysql_close(); //Make sure to close out the database connection