Result of a PHP & MySQL query with hyperlink

sansam

I have created 2 php files. One (sql_hyperlink.php) is a form which will accept inputs and display a list of records with employee id as a hyperlink. The next file (employee.php) will display the detail of the employee when the hyperlink is clicked.

The first part is working fine and the next page is opening with the correct id in the url, but somehow the variable emp_id is not retaining the value. Employee.php is not displaying anything! I have read several similar topics and tried various ways but missing something.

My codes are: sql_hyperlink.php

<table id = "hyperlinked_table" align="center" border="1" cellpadding="3">
    <tr><th>Employee ID</th><th>Name</th><th>Username</th></tr>
    <?php
        while ($result = mysqli_fetch_assoc($sql)) {
            $emp_id = $result['emp_id'];
            $fname = $result['first_name'];
            $lname = $result['last_name'];
            $uid = $result['username']
    ?>
    <tr> 
        <td> <?php echo '<a href="employees.php?id='.$emp_id.'">'.$emp_id.'</a>'; ?> </td>
        <td><?php echo $fname ?> <?php echo $lname ?> </td>
        <td><?php echo $uid ?> </td>
    </tr>
    <?php

        }
    ?>
</table>

employee.php

<body>
<?php
$emp_id = $_GET['emp_id'];
include 'db_connect.php';
$sql = mysqli_query($connect, "SELECT * FROM user_master WHERE emp_id =    '".$emp_id."'"); 
$result = mysqli_fetch_assoc($sql);
$emp_id = $result['emp_id'];
?>

<div id="mem_photo"></div>

  <table id="mem_details">
    <caption><b>Employee Details</b></caption>
    <tr>
    <td>Employee ID: <?php echo $emp_id ?></td>
    <td>Card Number: <input type="text" name="card_no"></td>
    <td>Employee Status: </td>          
    </tr>

If I echo the emp_id after the line

$emp_id = $_GET['emp_id'];

it does not display the id.

Can anyone please help me with this?

Gouda Elalfy

you give your param id name in your link ?id='.$emp_id.' :

$emp_id = $_GET['emp_id'];

should be:

$emp_id = $_GET['id'];

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

insert php mysql query in hyperlink

From Dev

PHP mysql query result to xml

From Dev

Mysql database does not show query result in php

From Dev

PHP/MYSQL query no result, encoding wrong?

From Dev

looping php mysql query till no result found

From Dev

mysql query result with join/concat in php codeigniter

From Dev

PHP not displaying result from MYSQL query

From Dev

PHP/MYSQL query no result, encoding wrong?

From Dev

Php MySql Query does not return a result

From Dev

Save mysql query result into a PHP array

From Dev

php array from result of mysql query

From Dev

Echo Result of MySQL SELECT Query in PHP

From Dev

Mysql/Php query grouping filter result

From Dev

MySQL doesn't output PHP query result

From Dev

mysql php: how to properly save a query result

From Dev

Storing MySQL query result into a PHP array

From Dev

php mysql update query gives an empty result

From Dev

Output mysql query result in a php variable

From Dev

PHP passing mysql query result to be displayed on another page

From Dev

how to check if mysql query return no result(record not found) using php?

From Dev

PHP MySQL Query of view returns 0 results when there should be a result

From Dev

PHP nested array from flat MySQL query result

From Dev

how to add a different css to last mysql query result using php

From Dev

How to display multiple result from MySql query using PHP

From Dev

How to display multiple result from MySql query using PHP error

From Dev

Query from php and in Mysql Workbench not same result for special char

From Dev

Having Trouble Getting a MySQL Query Result into a PHP Array

From Dev

How to query one result of genre from array genres in php and mysql?

From Dev

PHP Mysql how to show message when query return no result?

Related Related

  1. 1

    insert php mysql query in hyperlink

  2. 2

    PHP mysql query result to xml

  3. 3

    Mysql database does not show query result in php

  4. 4

    PHP/MYSQL query no result, encoding wrong?

  5. 5

    looping php mysql query till no result found

  6. 6

    mysql query result with join/concat in php codeigniter

  7. 7

    PHP not displaying result from MYSQL query

  8. 8

    PHP/MYSQL query no result, encoding wrong?

  9. 9

    Php MySql Query does not return a result

  10. 10

    Save mysql query result into a PHP array

  11. 11

    php array from result of mysql query

  12. 12

    Echo Result of MySQL SELECT Query in PHP

  13. 13

    Mysql/Php query grouping filter result

  14. 14

    MySQL doesn't output PHP query result

  15. 15

    mysql php: how to properly save a query result

  16. 16

    Storing MySQL query result into a PHP array

  17. 17

    php mysql update query gives an empty result

  18. 18

    Output mysql query result in a php variable

  19. 19

    PHP passing mysql query result to be displayed on another page

  20. 20

    how to check if mysql query return no result(record not found) using php?

  21. 21

    PHP MySQL Query of view returns 0 results when there should be a result

  22. 22

    PHP nested array from flat MySQL query result

  23. 23

    how to add a different css to last mysql query result using php

  24. 24

    How to display multiple result from MySql query using PHP

  25. 25

    How to display multiple result from MySql query using PHP error

  26. 26

    Query from php and in Mysql Workbench not same result for special char

  27. 27

    Having Trouble Getting a MySQL Query Result into a PHP Array

  28. 28

    How to query one result of genre from array genres in php and mysql?

  29. 29

    PHP Mysql how to show message when query return no result?

HotTag

Archive