0

I am trying to view data of a row in phpmyadmin.
I have a table of employees in my database. It is a leave management portal. I created a "view" button, so if an admin clicks on it, it should display the details of the employee and the leave requested/taken. But it doesn't seem to work.
Below is my code. I'm new to php

<table class='table table-hover table-responsive table-bordered'>

  <td>First Name</td>
  <td>
    <?php echo htmlspecialchars($FirstName, ENT_QUOTES);  ?>
  </td>

  </tr>
  <tr>
    <td>Last Name</td>
    <td>
      <?php echo htmlspecialchars($LastName, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>Leave Type</td>
    <td>
      <?php echo htmlspecialchars($LeaveType, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>From Date</td>
    <td>
      <?php echo htmlspecialchars($FromDate, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>To Date</td>
    <td>
      <?php echo htmlspecialchars($ToDate, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>Description</td>
    <td>
      <?php echo htmlspecialchars($Description, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>Admin Remark</td>
    <td>
      <?php echo htmlspecialchars($AdminRemark, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>Admin Remark Date</td>
    <td>
      <?php echo htmlspecialchars($AdminRemarkDate, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>Status</td>
    <td>
      <?php echo htmlspecialchars($Status, ENT_QUOTES);  ?>
    </td>
  </tr>
  <tr>
    <td>Read</td>
    <td>
      <?php echo htmlspecialchars($IsRead, ENT_QUOTES);  ?>
    </td>
  </tr>
  <td></td>
  <td>
    <a href='index.php' class='btn btn-danger'>Back to Leave History</a>
  </td>
  </tr>
</table>


<td>
</td>
</tr>


</tbody>
</table>
<tbody>

  <?php

    $id=isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');

    try {

        $query = "SELECT id, FirstName, LastName, LeaveType, FromDate, ToDate, Description, AdminRemark, AdminRemarkDate, Status, IsRead FROM tblleaves WHERE id = ? LIMIT 0,1";
        $stmt = $con->prepare( $query );
        $stmt->bindValue(1, $id, PDO::PARAM_STR);
        $stmt->execute();
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
        $FirstName = $row['FirstName
        $LastName = $row['LastName'];
        $LeaveType = $row['LeaveType'];
        $FromDate = $row['FromDate'];
        $ToDate = $row['ToDate'];
          $Description = $row['Description'];
        $AdminRemark = $row['AdminRemark'];
        $AdminRemarkDate = $row['AdminRemarkDate'];
        $Status = $row['Status'];
        $IsRead = $row['IsRead'];   
    }
    catch(PDOException $exception){
        die('ERROR: ' . $exception->getMessage());
    }
    ?>
4
  • 1
    What kind of error are you getting on the page? Also you have this character ` at the beginning of your file. Commented Nov 22, 2018 at 8:23
  • 2
    The line $FirstName = $row['FirstName is missing at least a '];. It probably should look like $FirstName = $row['FirstName']; Commented Nov 22, 2018 at 8:23
  • It seems you have a lot of errors in your code. Please let me know what is the error message currently. Commented Nov 22, 2018 at 10:15
  • html syntax for table is incorrect - you're missing some tr tags (there are only closing tags), tbody tag is outside table, etc. Commented Nov 22, 2018 at 11:01

1 Answer 1

1

You are querying the results and storing it in variables after your HTML. Since variables aren't set, HTML will not have those values and hence it's not printing any values.

Place query results on top and HTML at the bottom.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.