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

  • SEARCH
  • Home
  • 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 8373529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:41:51+00:00 2026-06-09T14:41:51+00:00

Basically I’ve created two php papes. One selects my entire table, and displays just

  • 0

Basically I’ve created two php papes. One selects my entire table, and displays just date, and id number from it. Each date has a link directing to a display.php file. It pulls the ID number with it to the next display.php page. What I want to do on the display.php file is to display the entire row using that PHP.

So I know that Select * from tablename WHERE id=1 will pull that data, but how to get the ID number into there WHERE statement?

This is the main page code:

// SQL query
$strSQL = “SELECT * FROM table1”;

// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);

// Loop the recordset $rs
            while($row = mysql_fetch_array($rs)) {

               // DATE
              $strName = $row['date'];

               // Create a link to display.php with the id-value in the URL
               $strLink = "<a href = 'display.php?ID = " . $row['ID'] . "'>" . $strName . "</a>";

                // List link
               echo "<li>" . $strLink . "</li>";


  }

That code links works and goes to display.php.
How would I create the link using the ID number pulling with it. Would I use a post command?

$id= Post['id'] 
then WHERE id = '$id'

?

TBH I did try that and got nothing. Any suggestions?

USING GET now…still not luck
I’ve tried the GET statement. In my address bar it shows the ID number. So I see the ID number pulling over with it. I tried even just echoing the ID to see if maybe it was just my code messing up.

<?php 
    $dbhost = 'localhost';
    $dbuser = 'myusername';
    $dbpass = 'mypw';
    $dbname = 'mydbname';
    $id = $_GET['id'];
    mysql_connect($dbhost, $dbuser, $dbpass) or die('MySQL connect failed. ' . mysql_error());
    mysql_select_db($dbname) or die('Cannot select database. ' . mysql_error());
?>


<body>
ID #<?php  echo $id ?>
</body>
</html>

<body>
ID #<?php  echo $id ?>
</body>
</html>

Still no luck

  • 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-06-09T14:41:53+00:00Added an answer on June 9, 2026 at 2:41 pm

    So in your display file you’d do something like this

    $id = $_GET['ID'];
    
    //DO SANITIZATION ETC ON THE ID HERE TO MAKE SURE ITS SOMETHING WE EXPECTED (AN INT)
    
    $sql = "SELECT STUFF WHERE ID = {$id}"; //FOR BREVITY SAKE DOING AWAY WITH SECURITY 
    

    So basically what your first script is doing is passing the id in the url query string, values passed here are accessible in the $_GET super globals array.

    Anything you access in here and the other super globals should be treated as completely dangerous to your application. You should filter and escape the hell out of it, and then before inserting it into the database you must escape it using the correct mechanism for your database. Otherwise you leave yourself open to SQL injection attacks.

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

Sidebar

Related Questions

Basically I have two models: User and Godfather. The godfather table has three columns:
Basically I am trying to restart a service from a php web page. Here
Basically from C++ FAQ I learned that: A virtual function allows derived classes to
Basically, I have a list of delivery checkboxes one for deliver to this address
Basically from a database I am getting data that is formatted like this nameofproject101
Basically I'm attempting to add rows to a table, I need to do this
Basically I have an iframe loaded that is accessed from the parent whenever it
Basically I am writing a simple bit of code to increment every one second
Basically I have a fixed size IFRAME with overflow: auto . The IFRAME displays
Basically, what signal does '0' represent, because here I see SIGNAL numbers starting from

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.