I am trying to make tables that display data on my web page but every timeI use the count function in my sql query I get the error Undefined index on line 19.
Position in/Library/WebServer/Documents/students/steve/Sites/tables.php on line 19
The php code looks like this.
<?php
include('db-connect.php');
include('top.php');
$query = 'SELECT Nationality, COUNT(Position)
FROM 2017_Crankworx_Results
WHERE Position = 1
GROUP BY Nationality
ORDER BY Nationality ASC';
$results = mysqli_query($link, $query) or die(mysqli_error($link));
echo '<table>';
echo '<th>Nationality</th>';
echo '<th>Position</th>';
echo '<br><br>';
while($crank = mysqli_fetch_assoc($results))
{
echo '<tr>';
echo '<td>'.$crank['Nationality'].'</td>';
echo '<td>'.$crank['Position'].'</td>';
echo '</tr>';
}
echo '</table>';
include('bottom.php');
mysqli_close($link);
?>
I you could tell me if there is something that not right with my code or if I am doing something else worng that would be great.