Note that there are some explanatory texts on larger screens.

plurals
  1. POSELECT * FROM Table Where ID
    primarykey
    data
    text
    <p>I am trying to retrieve information from my database depending on the ID a user types into my URL.</p> <p>For example: If USER A went to www.exampleurl.com/index.php?id=1 it would echo out the user's information which has an ID of 1. Same thing if the id was 2, 3, etc. Users are entering their information via a form in a different file called submit.php.</p> <p>Here is my code to retrieve data depending on ID :</p> <pre><code>&lt;?php $id = $_GET['id']; //Variables for connecting to your database. $hostname = ""; $username = ""; $dbname = ""; $password = ""; $usertable = ""; //Connecting to your database $con = mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later."); mysql_select_db($dbname, $con); $query = "SELECT * FROM $usertable WHERE id = $id LIMIT 1"; $result = mysql_query($query, $con); echo "Hello, " . $result['name']; ?&gt; </code></pre> <p>Any ideas on if my SELECT request is wrong? </p> <p><strong>EDIT</strong></p> <p>Here is my code for showing the data altogether in a table. This works fine.</p> <pre><code> &lt;?php //Variables for connecting to your database. $hostname = ""; $username = ""; $dbname = ""; $password = "!"; $usertable = ""; //Connecting to your database $con = mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later."); mysql_select_db($dbname, $con); //Fetching from your database table. $query = "SELECT * FROM $usertable"; $result = mysql_query($query, $con); echo "&lt;table border=1&gt; &lt;tr&gt; &lt;th&gt; ID &lt;/th&gt; &lt;th&gt; Name &lt;/th&gt; &lt;th&gt; Age &lt;/th&gt; &lt;/tr&gt;"; while($record = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $record['id'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $record['name'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $record['age'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload