wenxi Posted June 10, 2007 Share Posted June 10, 2007 User choose on ID and submit. I use the URL query method to get the ID and rest of the profile like first_name, last_name, I tried something like this $query = "SELECT * FROM user where user_id= $ID"; echo $_get['first_name']; but it doesnt show, how come? Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/ Share on other sites More sharing options...
r-it Posted June 10, 2007 Share Posted June 10, 2007 $query = "SELECT * FROM user where user_id= '$ID'"; Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271786 Share on other sites More sharing options...
wenxi Posted June 10, 2007 Author Share Posted June 10, 2007 no difference after editing ='$ID' Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271788 Share on other sites More sharing options...
r-it Posted June 10, 2007 Share Posted June 10, 2007 can you show us more of your code because that single line does not help Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271790 Share on other sites More sharing options...
wenxi Posted June 10, 2007 Author Share Posted June 10, 2007 <?php $ID = $_GET['listing']; echo "You have clicked $ID"; $first = $_GET['first_name']; ?> <?php //connect to database here $dbhost1 = 'localhost'; $dbuser1 = 'root'; $dbpass1 = ''; $conn1 = mysql_connect($dbhost1, $dbuser1, $dbpass1) or die(mysql_error()); $dbname1 = 'studportal'; mysql_select_db($dbname1); $query = "SELECT * FROM user where user_id= '$ID'"; $result = mysql_query ($query) ; echo $_get['first_name']; //echo $first; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ ?> if you need the full page, i can email to you Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271792 Share on other sites More sharing options...
r-it Posted June 10, 2007 Share Posted June 10, 2007 use this instead of the $_get['first_name'] $query = "SELECT * FROM user where user_id= '$ID'"; $result = mysql_query ($query) ; while($rec = mysql_fetch_array($result)) { echo $rec['first_name']; } Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271795 Share on other sites More sharing options...
wenxi Posted June 10, 2007 Author Share Posted June 10, 2007 Thanks I've Got IT! Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271802 Share on other sites More sharing options...
wenxi Posted June 10, 2007 Author Share Posted June 10, 2007 now having unknown errors, syntax error Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271813 Share on other sites More sharing options...
AndyB Posted June 10, 2007 Share Posted June 10, 2007 now having unknown errors, syntax error Post your code. Explain exactly what error messages you get. Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271814 Share on other sites More sharing options...
wenxi Posted June 10, 2007 Author Share Posted June 10, 2007 its say line 182 syntax error...when my line 182 is blank attached is the file. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/54964-retrieving-database-problem/#findComment-271819 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.