Hi,
I don't understand why my script below won't echo the first row in my mysqli table.
It starts from row 2. Any ideas why?
<?php
$link = mysqli_connect('localhost','mydatabase','password','username'); # Connect to database
$query = "SELECT * from mytable"; # Select what to query
$result = mysqli_query($link, $query); # Query table
echo "<table border=1>";
# echo table keys/titles
echo "<tr>";
foreach(mysqli_fetch_assoc($result) as $keys => $values) {
echo "<th align=left>".ucfirst($keys)."</th>";
}
echo "</tr>";
# echo table data
while ($rows = mysqli_fetch_assoc($result)) {
echo "<tr>";
foreach($rows as $row) {
print "<td>".$row."</td>";
}
echo "</tr>";
}
echo "</table>";
mysqli_free_result($result);
mysqli_close($link);
?>