I want to fetch data from Mysql database in list box..but it's not happening
The code is:

<?php
  		include("connection.php");
  
  			$sql= "select student_age from student_data";
  			$result= mysql_query($sql);
			if(!$result)
			{
			die('could not connect:'.mysql_error());
			}
			
  
  		while($row = mysql_fetch_array($result))
 		 {
		 echo "anumita";
  	?>
     <option value="<?=$row[0]?>">
    	 <?=$row[0]?>
   		</option>
  	<?php
 	 }
 	 ?>

Recommended Answers

All 2 Replies

Your code should work. The only things I see missing are the <select> tags to start and end the list box.

?><select><?
while($row = mysql_fetch_array($result))
...

Here is a tutorial for building a select box from MySQL data.

Populating a Select Box With PHP and MySQL

I think Jaseva is right. You probably will not see the select box without the select tags. Use View, Source to take a look at the code being generated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.