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
https://forums.phpfreaks.com/topic/212098-get/
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
https://forums.phpfreaks.com/topic/212098-get/#findComment-1105313
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
https://forums.phpfreaks.com/topic/212098-get/#findComment-1105325
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.