View Full Version : How to load data from mysql table to combobox
onetwo
August 11th, 2004, 05:17 PM
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
onetwo
August 11th, 2004, 06:39 PM
I found following:
http://forums.devarticles.com/archive/t-6645 (http://forums.devarticles.com/archive/t-6645)
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++) {
Should it not be: nrows ?? or ....
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.
If I manally replace: for (i=0; i<_root.listNum; i++) {
with
for (i=0; i<4; i++) {
it gives me a result. I just canøt figure this out.
sgorneau
This is my problem. I want to populate a combo box in Flash (http://forums.devarticles.com/archive/t-6645) with names in a MySQL (http://forums.devarticles.com/archive/t-6645) table. I've got a PHP (http://forums.devarticles.com/archive/t-6645) document that pulls all the names out of a MySQL database (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;
}
print (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);
}
}
//////////////////////////////////////////////////////////////
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.