FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » populate pulldownbox from query
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
populate pulldownbox from query [message #174051] Fri, 20 May 2011 18:30 Go to previous message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma:
Member
Hi All,

I am having trouble populating a pulldownbox with records from a table
in mySQL database.

I have a table with personnel records.
One of the fields is partner which holds a numeric value pointing to
the id of another record.
I am trying to get the value of the currently selected person's
partner.

for example:
id=1 name=John partner=2
id=2 name=Jane partner=1

With the code I use I do get the pulldownbox filled but it doesn't
display the name right partner info in the box.

$query="SELECT id, firstname, lastname, rank FROM myMembers WHERE id
<> $id ORDER BY lastname";
$result = mysql_query ($query);
echo "<select name=partner class=formFields id=partner
value=''>Partner</option>";
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[id]>$nt[rank] $nt[firstname] $nt[lastname]</
option>";
/* Option values are added by looping through the array */
}
echo "<option value=$partner>$nt[rank] $nt[firstname] $nt[lastname]</
option>";
echo "</select>";// Closing of list box
?>

Can anyone help me here?

Regards
Marco
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: he
Next Topic: Detecting Redirected Output
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 22:35:44 GMT 2024

Total time taken to generate the page: 0.05106 seconds