Database data not displaying on webpage












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());
}
?>









share|improve this question




















  • 1





    What kind of error are you getting on the page? Also you have this character ` at the beginning of your file.

    – RamonRobben
    Nov 22 '18 at 8:23








  • 2





    The line $FirstName = $row['FirstName is missing at least a '];. It probably should look like $FirstName = $row['FirstName'];

    – Eugene Anisiutkin
    Nov 22 '18 at 8:23













  • It seems you have a lot of errors in your code. Please let me know what is the error message currently.

    – Lajos Arpad
    Nov 22 '18 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.

    – barbsan
    Nov 22 '18 at 11:01
















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());
}
?>









share|improve this question




















  • 1





    What kind of error are you getting on the page? Also you have this character ` at the beginning of your file.

    – RamonRobben
    Nov 22 '18 at 8:23








  • 2





    The line $FirstName = $row['FirstName is missing at least a '];. It probably should look like $FirstName = $row['FirstName'];

    – Eugene Anisiutkin
    Nov 22 '18 at 8:23













  • It seems you have a lot of errors in your code. Please let me know what is the error message currently.

    – Lajos Arpad
    Nov 22 '18 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.

    – barbsan
    Nov 22 '18 at 11:01














0












0








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());
}
?>









share|improve this question
















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());
}
?>






php html mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 10:57









barbsan

2,45131223




2,45131223










asked Nov 22 '18 at 8:21









omoge willisomoge willis

1




1








  • 1





    What kind of error are you getting on the page? Also you have this character ` at the beginning of your file.

    – RamonRobben
    Nov 22 '18 at 8:23








  • 2





    The line $FirstName = $row['FirstName is missing at least a '];. It probably should look like $FirstName = $row['FirstName'];

    – Eugene Anisiutkin
    Nov 22 '18 at 8:23













  • It seems you have a lot of errors in your code. Please let me know what is the error message currently.

    – Lajos Arpad
    Nov 22 '18 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.

    – barbsan
    Nov 22 '18 at 11:01














  • 1





    What kind of error are you getting on the page? Also you have this character ` at the beginning of your file.

    – RamonRobben
    Nov 22 '18 at 8:23








  • 2





    The line $FirstName = $row['FirstName is missing at least a '];. It probably should look like $FirstName = $row['FirstName'];

    – Eugene Anisiutkin
    Nov 22 '18 at 8:23













  • It seems you have a lot of errors in your code. Please let me know what is the error message currently.

    – Lajos Arpad
    Nov 22 '18 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.

    – barbsan
    Nov 22 '18 at 11:01








1




1





What kind of error are you getting on the page? Also you have this character ` at the beginning of your file.

– RamonRobben
Nov 22 '18 at 8:23







What kind of error are you getting on the page? Also you have this character ` at the beginning of your file.

– RamonRobben
Nov 22 '18 at 8:23






2




2





The line $FirstName = $row['FirstName is missing at least a '];. It probably should look like $FirstName = $row['FirstName'];

– Eugene Anisiutkin
Nov 22 '18 at 8:23







The line $FirstName = $row['FirstName is missing at least a '];. It probably should look like $FirstName = $row['FirstName'];

– Eugene Anisiutkin
Nov 22 '18 at 8:23















It seems you have a lot of errors in your code. Please let me know what is the error message currently.

– Lajos Arpad
Nov 22 '18 at 10:15





It seems you have a lot of errors in your code. Please let me know what is the error message currently.

– Lajos Arpad
Nov 22 '18 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.

– barbsan
Nov 22 '18 at 11:01





html syntax for table is incorrect - you're missing some tr tags (there are only closing tags), tbody tag is outside table, etc.

– barbsan
Nov 22 '18 at 11:01












1 Answer
1






active

oldest

votes


















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.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426582%2fdatabase-data-not-displaying-on-webpage%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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.






    share|improve this answer




























      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.






      share|improve this answer


























        1












        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 8:24









        SamirSamir

        5,3242628




        5,3242628
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426582%2fdatabase-data-not-displaying-on-webpage%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            Npm cannot find a required file even through it is in the searched directory