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

Edited by Love2c0de
Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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