subhomoy Posted January 5, 2013 Share Posted January 5, 2013 Actually I'm trying to query database and show it in adrop down box in the registration page... I have done the code it is showing some errors... The code is shown below.... <?php require_once 'myconn.php'; $sql= "SELECT course_id, course_name, FROM course"; $result=mysql_query($sql); echo "<label>Select Course</label>"; while($row = mysql_fetch_array($result)) { echo "<select>; <option value='$row[course_id]'> $row[course_name] </option> </select>"; } ?> and it is showing in this manner.... Can anybody help me out where is the mistake... Quote Link to comment https://forums.phpfreaks.com/topic/272730-can-anyone-help-me/ Share on other sites More sharing options...
jazzman1 Posted January 5, 2013 Share Posted January 5, 2013 (edited) It shouldn't have a comma before the sql from clause! Edited January 5, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/272730-can-anyone-help-me/#findComment-1403441 Share on other sites More sharing options...
Love2c0de Posted January 5, 2013 Share Posted January 5, 2013 (edited) Hello, just had a look. Give this code a try: require_once 'myconn.php'; $sql = "SELECT course_id, course_name FROM course"; $result = mysql_query($sql); echo "<label>Select Course</label>"; echo "<select>"; while($row = mysql_fetch_array($result)) { echo "<option value='{$row['course_id']}'>{$row['course_name']}</option>"; } echo "</select>"; You might also want to check what the query returned before trying to use it's value. Hope it helps, Kind regards, L2c. Edited January 5, 2013 by Love2c0de Quote Link to comment https://forums.phpfreaks.com/topic/272730-can-anyone-help-me/#findComment-1403442 Share on other sites More sharing options...
subhomoy Posted January 5, 2013 Author Share Posted January 5, 2013 Hello, just had a look. Give this code a try: require_once 'myconn.php'; $sql = "SELECT course_id, course_name FROM course"; $result = mysql_query($sql); echo "<label>Select Course</label>"; echo "<select>"; while($row = mysql_fetch_array($result)) { echo "<option value='{$row['course_id']}'>{$row['course_name']}</option>"; } echo "</select>"; You might also want to check what the query returned before trying to use it's value. Hope it helps, Kind regards, L2c. Thanks buddy..... very much... Quote Link to comment https://forums.phpfreaks.com/topic/272730-can-anyone-help-me/#findComment-1403443 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.