<?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
foreach ($result as $row){
echo '<tr><td>' . htmlspecialchars($row['PersonID']) . '</td><td>' . htmlspecialchars($row['LastName']) . '</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