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. Quote Link to comment 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 } Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.