Jump to content

Can anyone help me...


subhomoy

Recommended Posts

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....

 

untitled.PNG

 

Can anybody help me out where is the mistake...

Link to comment
https://forums.phpfreaks.com/topic/272730-can-anyone-help-me/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/272730-can-anyone-help-me/#findComment-1403442
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/272730-can-anyone-help-me/#findComment-1403443
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.