selected value get from db into dropdown select box option using php mysql error

0 votes

I have to get the selected value from the database into the select box. Please explain the process to me. This is the code. Note that the value of "options" depends on the category. 

<?php 
  $sql = "select * from mine where username = '$user' ";
  $res = mysql_query($sql);
  while($list = mysql_fetch_assoc($res)){
    $category = $list['category'];
    $username = $list['username'];
    $options = $list['options'];
?>

<input type="text" name="category" value="<?php echo '$category' ?>" readonly="readonly" />
<select name="course">
   <option value="0">Please Select Option</option>
   <option value="PHP">PHP</option>
   <option value="ASP">ASP</option>
</select>

<?php 
  }
?>

Can someone please help me with this?

Jul 31, 2022 in PHP by Kithuzzz
• 38,000 points
4,774 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,363 views
0 votes
1 answer

How to get input field value using PHP?

Hello, Use PHP's $_POST or $_GET superglobals to retrieve the value of ...READ MORE

answered Nov 20, 2020 in PHP by Niroj
• 82,840 points
73,478 views
0 votes
0 answers

PHP: Inserting Values from the Form into MySQL

I created a user table in MySQL from the ...READ MORE

Jun 7, 2022 in PHP by Kichu
• 19,040 points
423 views
0 votes
0 answers

How can I store and retrieve images from a MySQL database using PHP?

How can I insert an image in ...READ MORE

Jun 14, 2022 in PHP by narikkadan
• 63,600 points
489 views
0 votes
0 answers

How to upload images into MySQL database using PHP code

I'm attempting to save photos from an ...READ MORE

Aug 3, 2022 in PHP by Kithuzzz
• 38,000 points
1,531 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
1,300 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,543 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,250 points
1,272 views
0 votes
2 answers
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP