Not getting data in list box

Reply

Join Date: Nov 2008
Posts: 13
Reputation: anumitadas is an unknown quantity at this point 
Solved Threads: 0
anumitadas anumitadas is offline Offline
Newbie Poster

Not getting data in list box

 
0
  #1
Nov 22nd, 2008
I want to fetch data from Mysql database in list box..but it's not happening
The code is:
  1. <?php
  2. include("connection.php");
  3.  
  4. $sql= "select student_age from student_data";
  5. $result= mysql_query($sql);
  6. if(!$result)
  7. {
  8. die('could not connect:'.mysql_error());
  9. }
  10.  
  11.  
  12. while($row = mysql_fetch_array($result))
  13. {
  14. echo "anumita";
  15. ?>
  16. <option value="<?=$row[0]?>">
  17. <?=$row[0]?>
  18. </option>
  19. <?php
  20. }
  21. ?>
Last edited by peter_budo; Nov 24th, 2008 at 6:25 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 104
Reputation: Jaseva is an unknown quantity at this point 
Solved Threads: 0
Jaseva's Avatar
Jaseva Jaseva is offline Offline
Junior Poster

Re: Not getting data in list box

 
0
  #2
Nov 22nd, 2008
Your code should work. The only things I see missing are the <select> tags to start and end the list box.

  1. ?><select><?
  2. while($row = mysql_fetch_array($result))
  3. ...
~Jaseva
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 87
Reputation: TopDogger is an unknown quantity at this point 
Solved Threads: 5
TopDogger's Avatar
TopDogger TopDogger is offline Offline
Junior Poster in Training

Re: Not getting data in list box

 
0
  #3
Nov 24th, 2008
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.
Last edited by TopDogger; Nov 24th, 2008 at 8:51 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 738 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC