# How to load data from mysql table to combobox

**URL:** <https://forum.kirupa.com/t/how-to-load-data-from-mysql-table-to-combobox/119140>\
**Category:** Uncategorized\
**Created:** [August 11, 2004, 9:17pm UTC](https://forum.kirupa.com/t/how-to-load-data-from-mysql-table-to-combobox/119140 "2004-08-11T21:17:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![onetwo](https://avatars.discourse-cdn.com/v4/letter/o/3d9bf3/32.png) [@onetwo](https://forum.kirupa.com/u/onetwo)\
**Post date:** [August 11, 2004, 9:17pm UTC](https://forum.kirupa.com/t/how-to-load-data-from-mysql-table-to-combobox/119140/1 "2004-08-11T21:17:43Z")

</div>

Hi,  
How do I load data from a mysql table to a combobox using php and AS ?

I do know how to retrieve the data from my table needed but how is this inserted the combobox ?

Assume you have combobox1 and combobox2.  
When I, in combobox1 select: ‘cars’ I would now like the script to search my table for cars in the column ‘stuff’ and then insert the result in combobox2.

I hope you can help or have some suggestions

best regards

---

<div class="post-metadata">

**Author:** ![onetwo](https://avatars.discourse-cdn.com/v4/letter/o/3d9bf3/32.png) [@onetwo](https://forum.kirupa.com/u/onetwo)\
**Post date:** [August 11, 2004, 10:39pm UTC](https://forum.kirupa.com/t/how-to-load-data-from-mysql-table-to-combobox/119140/2 "2004-08-11T22:39:28Z")

</div>

I found following:  
[font=Verdana][[color=#800080]http://forums.devarticles.com/archive/t-6645[/color]](http://forums.devarticles.com/archive/t-6645)[/font]

[font=Verdana] [/font]  
[font=Verdana]It works fine just I do not get the value forwarded from php to the AS. That is: \_root.listNum in the line for (i=0; i\<\_root.listNum; i++) {[/font]  
[font=Verdana]Should it not be: nrows ?? or …[/font]  
[font=Verdana]From php I can forward no of hits to a Dynamic Text but I can not get the variable as just mentioned. Why is that ??? And this is a problem for not just this script.[/font]  
[font=Verdana]If I manally replace: for (i=0; i\<\_root.listNum; i++) { [/font]  
[font=Verdana] with[/font]  
[font=Verdana]for (i=0; i\<4; i++) {[/font]  
[font=Verdana]it gives me a result. I just canøt figure this out.[/font]  
[font=Verdana][font=Times New Roman][/font][/font]  
[font=Verdana][/font]  
[font=Times New Roman] **sgorneau** [/font]

[font=‘Times New Roman’]This is my problem. I want to populate a combo box in [[color=#800080]Flash[/color] with names in a [url=“http://forums.devarticles.com/archive/t-6645”][color=#800080]MySQL[/color] table. I’ve got a [url=“http://forums.devarticles.com/archive/t-6645”][color=#800080]PHP[/color] document that pulls all the names out of a MySQL [url=“http://forums.devarticles.com/archive/t-6645”][color=#800080]database[/color]](http://forums.devarticles.com/archive/t-6645) table. For each row in the table, It pulls the string from ‘lname’ and ‘fname’, and then creates a variable variable to hold the value of $lname.", ".$fname. The script looks like this…

//////////////////////////////////////////////////////////////

$qr = “SELECT \* FROM playerInfo ORDER BY lname”;  
$re = mysql\_query($qr) or die("\<br /\>Could’t run query!");  
$nrows = mysql\_num\_rows($re);

for ($i=0; $i\<$nrows; $i++){  
$player = “player”.$i;  
$lname = mysql\_result($re,$i,“lname”);  
$fname = mysql\_result($re,$i,“fname”);  
$$player = $lname.", ".$fname;  
$output .= “&player$i=”.$$player;  
}

[[color=#800080]print[/color]](http://forums.devarticles.com/archive/t-6645) “&listNum=$nrows”.$output;

//////////////////////////////////////////////////////////////

I am sending the variable ‘listNum’ so I can tell Flash how many times to run it’s own loop to populate a combobox.

Now here’s the actionscript…

//////////////////////////////////////////////////////////////

\_root.listNum = “”;  
loadVariablesNum(“populateListBox.php”, “0”);  
popListBoxID = setInterval(popListBox, 50);  
function popListBox() {  
if (\_root.listNum != “”) {  
for (i=0; i\<\_root.listNum; i++) {  
\_root.userNames.addItem(“player”+i); //\<-PROBLEM  
}  
clearInterval(popListBoxID);  
}  
}

//////////////////////////////////////////////////////////////[/font]
