Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 876237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:24:06+00:00 2026-05-15T11:24:06+00:00

I have a table generated from some PHP code that lists a SMALL amount

  • 0

I have a table generated from some PHP code that lists a SMALL amount of important information for employees. I want to make it so each row, or at least one element in each row can be clicked on so the user will be redirected to ALL of the information (pulled from MySQL database) related to the employee who was clicked on. I am not sure how would be the best way to go about this, but I am open to suggestions. I would like to stick to PHP and/or JavaScript. Below is the code for my table:

        <table>

            <tr>

                <td id="content_heading" width="25px">ID</td>
                <td id="content_heading" width="150px">Last Name</td>
                <td id="content_heading" width="150px">First Name</td>
                <td id="content_heading" width="75px">SSN</td>

            </tr>

            <?php

                $user = 'user';
                $pass = 'pass';
                $server = 'localhost';

                $link = mysql_connect($server, $user, $pass);

                if (!$link){
                    die('Could not connect to database!' . mysql_error());
                }

                mysql_select_db('mydb', $link);
                $query = "SELECT * FROM employees";
                $result = mysql_query($query);
                mysql_close($link);

                $num = mysql_num_rows($result);                         

                for ($i = 0; $i < $num; $i++){

                    $row = mysql_fetch_array($result);

                    $class = (($i % 2) == 0) ? "table_odd_row" : "table_even_row";

                    echo "<tr class=".$class.">";

                        echo "<td>".$row[id]."</td>";
                        echo "<td>".$row[l_name]."</td>";
                        echo "<td>".$row[f_name]."</td>";
                        echo "<td>".$row[ssn]."</td>";

                    echo "</tr>";

                }

            ?>      

        </table>

EDIT

Ok, after modifying what @DrColossos posted I have been able to get my links to work correctly, but now I’m having trouble with the uniqueness part. Below is the code I am now using to create my table:

                        echo "<td><a href=Edit_Employee.php?".$row[id].">".$row[id]."</a></td>";
                        echo "<td><a href=Edit_Employee.php?".$row[id].">".$row[l_name]."</a></td>";
                        echo "<td><a href=Edit_Employee.php?".$row[id].">".$row[f_name]."</a></td>";
                        echo "<td><a href=Edit_Employee.php?".$row[id].">".$row[ssn]."</a></td>";

This makes all of the elements of a row hyperlink to Edit_Employee.php?**id**. For instance if the id was one the hyperlink would be Edit_Employees.php?1. Now what do I need to do in my Edit_Employee.php page to get or recognize the id in the link, because it is that id that is unique and that is what I need to base my MySQL search on.

EDIT

Figured it out. This did the trick:

$id = $_GET['id'];

I found that creating my links as I did makes the id a global variable which PHP can pull from the hyperlink. I used the code above in the page that the hyperlink points to and I was able to get what I wanted. Not too hard, but frustrating if you don’t know how it is done!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:24:07+00:00Added an answer on May 15, 2026 at 11:24 am

    You can already create an unique link with the “ID” of each employee.

    You could do the following:

     echo "<td><a href="employee.php?id=\"" . $row['id'] . "\">" . $row['id'] . "</td>";
    

    or more readable

     echo "<td><a href="employee.php?id=\"{$row['id']}\">{$row['id']}</td>";
    

    Then you can use the employee.php to display it’s detail (the id will be in $_GET[‘id’], see here). Don’t forget to check the value of $_GET[‘id’] before you process it, since it can contain harmfull data (e.g. SQL-Injection).

    BTW, the HTML attribute ‘id’ that you use in the table id="content_heading" is supposed to be unique on the site, just as a site note.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this: insert into [table] ([data]) output inserted.id, inserted.data into… May 16, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer Yes, that's how lock is designed to work. The lock… May 16, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer To check for undefined: if (typeof x !== 'undefined') {… May 16, 2026 at 11:34 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have some data that I have to display as a table. I think
Quick question, looking for some recommendations. I have a site that will be requesting
I have the following HTML (excerpt from larger code-base) <div class=diary-event ui-corner-all title=[title]> <span
LANGUAGE: C#, System: Windows7, Excel 2007 I want to create a .DBF from some
I have a table with some ice cream order data like so: id order_number
I have an app that works with an idea of redemption codes (schema: ID,
I've been trudging through some code for two days trying to figure out why
Based on my research, it seems that what I want to do is not
I just had some basic php questions to further my understanding as I learn,
I have a MySQL database of newspaper articles. There's a volume table, an issue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.