marco839 Posted August 17, 2007 Share Posted August 17, 2007 Hiya, I'm trying to use the idea of file.php?id=1 to grab a row and display it on the page. below is my script.. <?php $id = $_GET['id']; mysql_connect("LOCALHOST", "USERNAME", "PASSWORD"); mysql_select_db("DATABASE") or die( "Unable to connect to database"); $result = mysql_query("SELECT * FROM linkcount WHERE id='$id'"); $row = mysql_fetch_array($result); echo "Name: ".$row["name"]; echo "<br>Addres: ".$row["address"]; echo "<br>Postcode: ".$row["postcode"]; echo "<br>Telephone: ".$row["telephone"]; echo "<br>Website: ".$row["website"]; ?> I'm trying to have the system load from id1 the details (e.g. file.php?id=2 will load row #2.. 3 #3... etc) But, it won't display and information - any ideas? Thanks very much for any help, Marco Quote Link to comment https://forums.phpfreaks.com/topic/65471-solved-newbie-query-get-command/ Share on other sites More sharing options...
nathanmaxsonadil Posted August 17, 2007 Share Posted August 17, 2007 try changing $result = mysql_query("SELECT * FROM linkcount WHERE id='$id'"); to $result = mysql_query("SELECT * FROM linkcount WHERE id='{$id}'"); Quote Link to comment https://forums.phpfreaks.com/topic/65471-solved-newbie-query-get-command/#findComment-326891 Share on other sites More sharing options...
marco839 Posted August 17, 2007 Author Share Posted August 17, 2007 Thank you - that's great, i've been pulling hair out trying to work this out. Query though, (As I want to learn more...), why do the {}'s need to be around the id bit? Quote Link to comment https://forums.phpfreaks.com/topic/65471-solved-newbie-query-get-command/#findComment-326900 Share on other sites More sharing options...
nathanmaxsonadil Posted August 17, 2007 Share Posted August 17, 2007 lol I'm not sure but you need it around a variable also it does'nt work inside ' ' quotes Quote Link to comment https://forums.phpfreaks.com/topic/65471-solved-newbie-query-get-command/#findComment-326901 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.