Jump to content

GET


Toy

Recommended Posts

I'm doing a PHP project and i'm pretty new to the thing so I need help.

 

I have a table with ID's in every row and I wan't to use the GET function.

 

/index.php?id=1 will display the content of the let's say name in the same row as the ID.

 

If there's no id= specified or it's invalid it'll just show the ordinary frontpage, like that.

 

:confused:

Link to comment
Share on other sites

Just one more thing, I have this code in the "if id is selected".

 

if(isset($_GET['id'])) {

$result = mysql_query("SELECT * FROM table");

while($display = mysql_fetch_array($result))

  {

echo $display['title'];

  }

} else {

 

Will display all the titles in the database, I want it to show and recognize from which ID is selected!

Link to comment
Share on other sites

You'll need to alter your SQL query to include a WHERE clause

$result = mysql_query("SELECT * FROM table WHERE title_ild='" . mysql_real_escape_string($_GET['id'] . "'");

 

Change title_id to the id column in your table.

 

I got the error: Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\index.php on line 14

 

I don't really know why, the code that you just wrote looks good to me? Any help? :S

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.