HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
list box populating?
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
techker



Joined: 30 Mar 2008
Posts: 1

PostPosted: Sun Mar 30, 2008 3:44 pm     list box populating? Reply with quote

hey guys im pulling out my hair here trying to figure out how to make a selectable drop down list box that populates it's self from my database..

i got it going but it does not selct ?and i need to submit to get the values..

Code:

<? echo "<select name='selectbox'>";

while($row=mysql_fetch_array($results))

{

echo "<option value='".$row['id']."'>".$row['name']."</option>";

}

echo "</select>"; ?>
rsleventhal



Joined: 19 Mar 2008
Posts: 20

PostPosted: Fri Apr 04, 2008 11:43 am     Re: list box populating? Reply with quote

techker wrote:


Code:

<? echo "<select name='selectbox'>";

while($row=mysql_fetch_array($results))

{

echo "<option value='".$row['id']."'>".$row['name']."</option>";

}

echo "</select>"; ?>


Hi techker,

I assume you've performed a query something along the lines of:
Code:

$sql = "select * from sometable";
$results = mysql_query($sql);

If that's the case, try changing
Code:
while($row=mysql_fetch_array($results))

to
Code:
while($row=mysql_fetch_assoc($results))


Beyond that, without more of the code to review, I don't know what to suggest.

HTH,
-Ray
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial