I'm querying some data from a mysql database and this all works perfectly on my live version of the site hosted at blahblah. I then re-created the database on my local machine for development so I can play with some real data. My issue is, in the HTML section of the code, It's giving me
Notice: Undefined index: boarded
It says this for each of the entries it's trying to echo. I know for a fact that the array it's pulling from does have an element "boarded" and so on.
Here is the first entry of the array dump.
results.array(101){ [0]=> array(7) { ["boarded"]=>
> string(1) "5" ["stop"]=> string(11) "Anthony - N" ["timestamp"]=>
> string(19) "2019-02-02 19:06:13" ["date"]=> string(10) "2019-02-02"
> ["loop"]=> string(9) "Blue Loop" ["driver"]=> string(5) "Yikes"
> ["id"]=> string(3) "368" }
HTML Section
<table>
<tr>
<th>Boarded</th>
<th>Stop</th>
<th>Timestamp</th>
<th>Date</th>
<th>Loop</th>
<th>Driver</th>
<th>ID</th>
</tr>
<? foreach ($log as $logs): ?>
<tr>
<td><?= $logs["boarded"] ?></td>
<td><?= $logs["stop"] ?></td>
<td><?= $logs["timestamp"] ?></td>
<td><?= $logs["date"] ?></td>
<td><?= $logs["loop"] ?></td>
<td><?= $logs["driver"] ?></td>
<td><?= $logs["id"] ?></td>
</tr>
<? endforeach ?>
</ul>
</table>
Array being created
if($result = mysqli_query($con,$sql))
{
$cr = 0;
while($row = mysqli_fetch_assoc($result))
{
$logs[$cr]['boarded'] = $row['boarded'];
$logs[$cr]['stop'] = $row['stop'];
$logs[$cr]['timestamp'] = $row['timestamp'];
$logs[$cr]['date'] = $row['date'];
$logs[$cr]['loop'] = $row['loop'];
$logs[$cr]['driver'] = $row['driver'];
$logs[$cr]['id'] = $row['id'];
$cr++;
}
}
Any ideas?