Toy Posted August 30, 2010 Share Posted August 30, 2010 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. Link to comment https://forums.phpfreaks.com/topic/212098-get/ Share on other sites More sharing options...
AbraCadaver Posted August 30, 2010 Share Posted August 30, 2010 if(isset($_GET['id'])) { // do sql query using id and display } else { // display ordinary frontpage } Link to comment https://forums.phpfreaks.com/topic/212098-get/#findComment-1105308 Share on other sites More sharing options...
Toy Posted August 30, 2010 Author Share Posted August 30, 2010 if(isset($_GET['id'])) { // do sql query using id and display } else { // display ordinary frontpage } I'm pretty sure that that'll do it! Thank's man you're a lifesaver. Link to comment https://forums.phpfreaks.com/topic/212098-get/#findComment-1105309 Share on other sites More sharing options...
Toy Posted August 30, 2010 Author Share Posted August 30, 2010 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 More sharing options...
wildteen88 Posted August 30, 2010 Share Posted August 30, 2010 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. Link to comment https://forums.phpfreaks.com/topic/212098-get/#findComment-1105320 Share on other sites More sharing options...
Toy Posted August 30, 2010 Author Share Posted August 30, 2010 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 More sharing options...
wildteen88 Posted August 30, 2010 Share Posted August 30, 2010 Oops. I didn't close the function properly $result = mysql_query("SELECT * FROM table WHERE title_id='" . mysql_real_escape_string($_GET['id']) . "'"); Remember to change title_id to your actual id column Link to comment https://forums.phpfreaks.com/topic/212098-get/#findComment-1105327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.