943,929 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1253
  • PHP RSS
Nov 22nd, 2008
0

Not getting data in list box

Expand Post »
I want to fetch data from Mysql database in list box..but it's not happening
The code is:
php Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anumitadas is offline Offline
17 posts
since Nov 2008
Nov 22nd, 2008
0

Re: Not getting data in list box

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

html Syntax (Toggle Plain Text)
  1. ?><select><?
  2. while($row = mysql_fetch_array($result))
  3. ...
Reputation Points: 17
Solved Threads: 3
Junior Poster
Jaseva is offline Offline
111 posts
since Jan 2007
Nov 24th, 2008
0

Re: Not getting data in list box

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.
Reputation Points: 15
Solved Threads: 5
Junior Poster in Training
TopDogger is offline Offline
87 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC