0

I am trying to build an interface for a manager who has a variable number of people they are responsible for. This number can, in theory, go up and down, so the size of the table will be different.

<?php if ($_SESSION['type'] === 'rm') : ?>
      <div class="table-area">
        <table class="client-table">
          <thead>
            <tr>
              <th>Client Name</th>
              <th>Client Email</th>
              <th>Client Location</th>
              <th>Client Phone</th>
            </tr>
          </thead>
          <tbody class="table-data">
            <?php
            for ($i = 0; $i < count($_SESSION['clients']); $i++) {
              echo '<tr>
            <td><a href="./user.php">' . $_SESSION['clients'][$i]['first_name'] . ' ' . $_SESSION['clients'][$i]['last_name'] . '</a></td>
            <td>' . $_SESSION['clients'][$i]['email'] . '</td>
            <td>' . $_SESSION['clients'][$i]['location'] . '</td>
            <td>' . $_SESSION['clients'][$i]['phone'] . '</td>
          </tr>';
            }
            ?>
          </tbody>
        </table>
      </div>
    <?php endif ?>

Ideally, I want the behaviour to be that once the manager clicks on the name of their client, it goes to their page, and I am planning on passing it by a $_SESSION['client'] variable, which will be an assoc array. To set this, I am going to use an ajax solution similiar to this solution how to extract text from a html element by id and assign to a php variable? . The reason I am choosing $_SESSION and not $_COOKIE is that its easier to reset the $_SESSION variables each time the manager selects a different client.

My problem is, I have the link set to their name (as it makes most sense from a UI/UX perspective), but need to somehow extract their email (as it is unique) or their entire row of data, but I'm having a difficult time grokking how to do that, especially when table rows and table data elements dont have IDs to specifically select from.

nos codemos
  • 569
  • 1
  • 5
  • 19

0 Answers0