I have an array of arrays. Each array contains a user's information (name, email, username, etc). When a user is logged in, the page needs to display the arrays in a table. (This is working fine)
<table>
<?php
if(isset($_SESSION['logged_in_user'])) {
echo '<tr>';
for ($i = 0; $i < count($item_names); $i++) {
if ($i == 8) continue;
echo "<th scope=\"col\">$item_names[$i]</th>";
}
echo '</tr>';
$altrow = false;
foreach ($contacts as $contact) {
echo ($altrow) ? '<tr class="alt">' : '<tr>';
$altrow = !$altrow;
for ($i = 0; $i < count($contact); $i++) {
if ($i == 8) continue;
echo "<td>$contact[$i]</td>";
}
echo '</tr>';
}
}
?>
</table>
But I would also like the table to highlight the array(row) of the specific logged in user.
I have tried (and failed):
<table>
<?php
if(isset($_SESSION['logged_in_user'])) {
echo '<tr>';
for ($i = 0; $i < count($item_names); $i++) {
if ($i == 8) continue;
echo "<th scope=\"col\">$item_names[$i]</th>";
}
echo '</tr>'
$altrow = false;
foreach ($contacts as $contact) {
if ($contact[1] == $_SESSION['logged_in_user']) {
echo '<tr class="highlight">' : '<tr>';
} else {
echo ($altrow) ? '<tr class="alt">' : '<tr>';
$altrow = !$altrow;
for ($i = 0; $i < count($contact); $i++) {
if ($i == 8) continue;
echo "<td>$contact[$i]</td>";
}
}
echo '</tr>';
}
}
?>
</table>
Am I not even close? Any help is appreciated!