Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox load problems

Status
Not open for further replies.

MJB3K

Programmer
Jul 16, 2004
524
0
0
GB
Hi, i am tryin to populate a listbox from a php page, but doesnt seem 2 work properly

php code:
Code:
<?php
include "../../nep-yb/config.php";

$i=0;

$qT = mysql_query("SELECT uid FROM member");
$amt = mysql_num_rows($qT);
echo "&amnt=$amt";
//
$i=0;
$q = mysql_query("SELECT uid, nick FROM member") or die(mysql_error());
	while(list($uid,$n) = mysql_fetch_row($q)){
		echo "&user[$i]=$n&uid[$i]=$uid";
		$i++;
	}
?>
flash code:
Code:
//init
lv = new LoadVars();
lv.onLoad = function() {
	for (var i = 0; i<this.amnt; i++) {
		userList.addItem({label:this[user+i], data:this[uid+i]});
	}
};
lv.sendAndLoad('[URL unfurl="true"]http://www.webrevolt.biz/work/lobby/getUserList.php',[/URL] lv, 'post');
function showMenu() {
	trace(userList.selectedItem.data);
}
//
userList.addEventListener("change", showMenu);

in the box, i get undefiend, undefiend

why is this??

what is wrong with the code??


Regards,

Martin

Gaming Help And Info:
 
assuming php is ok...and i have to say first impression is a bid dodgy...as1 solution
Code:
	lv = new LoadVars();
	lv.sendAndLoad("[URL unfurl="true"]http://www.me.com",[/URL] lv, "POST");
	lv.onLoad = function() {
		for (i=0; i<this.amnt; i++) {
			userlist.addItem(this["user"+i], this["uid"+i]);
		};
};
 
then i am sure its the php code thats wrong...for starters i see no command to connect to mysql or open a database...but those commands may be in include file...cant tell

however before you dig into that add a trace to onload function and examine the output...clues may well be there

lv.onLoad = function() {
trace(this);
for (i=0; i<this.amnt; i++) {
userlist.addItem(this["user"+i], this["uid"+i]);
};
};
 
still doesn't work :(


^^ url thats loading

i don't know why it is not working, keeps coming up undefind for some reason?

Code:
lv = new LoadVars();
lv.sendAndLoad("[URL unfurl="true"]http://www.webrevolt.biz/work/lobby/getUserList.php",[/URL] lv, "POST");
lv.onLoad = function() {
	trace("user: "+this.user + " | uid: "+this.uid);
	trace(this);
	for (i=0; i<this.amnt; i++) {
		userList.addItem({ label:this["user"+i], data: this["uid"+i]});
	}
};



Regards,

Martin

Gaming Help And Info:
 
It's probably the [] brackets in your name/value pairs. Remove them.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top