PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 7th, 2004, 08:47 AM
sean2004 sean2004 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 11 sean2004 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Why My Drop Down List is Empty? Help!!! Pls...

Hello!

I have been trying to find an answer for this one...
all i am trying to do is...populating a drop down list from a
mysql db...why is my drop down list empty?

whats wrongwith the below code...?

<HTML>

<select name="home_name">
<?php

include "mysql_data.inc";

$strsql = "select * from homes";

$rsTmp = mysql_query($strsql) or die("Query failed");

while($rowTmp = mysql_fetch_array($rsTmp,MYSQL_ASSOC)) { ?>
echo "<option><?=$rowTmp[0]?></option> ";
<?php } ?>
</select>

?>

</HTML>

Reply With Quote
  #2  
Old October 7th, 2004, 09:17 PM
eddynazrul eddynazrul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: 192.168.1.4
Posts: 21 eddynazrul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I don't know what is wrong with that code.. Suddenly when i move the MYSQL_ASSOC,
it works like a champ.

This is the code after i make the changes..

Quote:
<select name="home_name">
<?php
$strsql = "select * from Player";
$rsTmp = mysql_query($strsql) or die("Query failed");
while($rowTmp = mysql_fetch_array($rsTmp)) {
echo "<option value='$rowTmp[0]'>$rowTmp[0]</option> ";
}
?>
</select>

Change table Player with your table in db

Reply With Quote
  #3  
Old October 8th, 2004, 09:59 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Why did you post your question twice?
refer to the answer in http://forums.devarticles.com/t10261/s.html

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Why My Drop Down List is Empty? Help!!! Pls...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT