PDA

View Full Version : Flash, PHP & MySQL



lbeetles
September 18th, 2003, 06:10 AM
I have a site that is using a MySQL database and PHP to display it in flash. I have a listbox which i want to sort by order of peoples names from the database, how do i do this???

My database is called FOOTBALL, my table is called PLAYERS and the fields in the table are ID, NAME, DOB, POS, NUMBER, IMAGE, APPS, GOALS, ASSISTS, YELLOW, and RED.

here is the PHP code:


<?
include("config.inc.php");
$connessione = @mysql_connect($server,$user,$pass);
$database = mysql_select_db($database,$connessione);


$select = "SELECT * FROM players";
$result = mysql_query($select);
$rows = mysql_num_rows($result);
while($list = mysql_fetch_array($result)){

$id = $list["id"];
$name = $list["name"];
$dob = $list["dob"];
$pos = $list["pos"];
$number = $list["number"];
$image = $list["image"];
$apps = $list["apps"];
$goals = $list["goals"];
$assists = $list["assists"];
$yellow = $list["yellow"];
$red = $list["red"];

print("Total=$rows&Oggetto$id=$name|$dob|$pos|$number|$image|$apps|$g oals|$assists|$yellow|$red&");
}
?>

I think i have to use something like SELECT name FROM players ORDER BY name; but i don't know where to put this code.

Any help would be greatful.

λ
September 18th, 2003, 10:54 AM
$query = "SELECT * FROM players ORDER BY name";


that should do it :)

lbeetles
September 18th, 2003, 11:00 AM
thanx njs12345, but where in my code do i put this query???

λ
September 18th, 2003, 11:02 AM
sorry, just replace your current query with that SQL:


<?
include("config.inc.php");
$connessione = @mysql_connect($server,$user,$pass);
$database = mysql_select_db($database,$connessione);


$select = "SELECT * FROM players ORDER BY name";
$result = mysql_query($select);
$rows = mysql_num_rows($result);
while($list = mysql_fetch_array($result)){

$id = $list["id"];
$name = $list["name"];
$dob = $list["dob"];
$pos = $list["pos"];
$number = $list["number"];
$image = $list["image"];
$apps = $list["apps"];
$goals = $list["goals"];
$assists = $list["assists"];
$yellow = $list["yellow"];
$red = $list["red"];

print("Total=$rows& Oggetto$id=$name|$dob|$pos|$number|$image|$apps|$g oals|$assists|$yellow|$red&");
}
?>

lbeetles
September 18th, 2003, 11:05 AM
cheers again, but i had already tried this and its not working. Any other ideas???

Jubba
September 18th, 2003, 02:33 PM
that is definatly the solution. what are you actually getting for output?

lbeetles
September 18th, 2003, 04:12 PM
when i open the php page in a browser it works and displays them as i want it to. But in flash it dosn't go in alphabetical order. Do you know why???

Jubba
September 18th, 2003, 07:54 PM
well what is your flash code? :)

eyezberg
September 19th, 2003, 02:40 AM
do you prefer answers here or on phpforflash? i won't post on both... :)

lbeetles
September 19th, 2003, 04:15 AM
Cheers eyezberg,

I would prefer answers here if you don't mind, and thanx for the help.

Jubba,

here is my flash code its on the time line and when you click on the listbox it uses the selectPlayers function:


players = new LoadVars()
_root.comboname.setAutoHideScrollBar(true);
players.load("Select.php")
players.onLoad = function(success){
for(this.a=1;this.a<=players.total;this.a++){
players["object"+this.a] = players["Oggetto"+(this.a)].split("|")
_root.comboname.addItem(players["object"+this.a][0])
delete(this["Oggetto"+this.a])
}
}

function selectPlayers (){
selected = _root.comboname.getSelectedIndex()
_root.name.text = _root.players["object"+selected][0]
_root.dob.text = _root.players["object"+selected][1]
_root.pos.text = _root.players["object"+selected][2]
_root.number.text = _root.players["object"+selected][3]
loadMovie(_root.players["object"+selected][4]+".jpg","object_image")
_root.apps.text = _root.players["object"+selected][5]
_root.goals.text = _root.players["object"+selected][6]
_root.assists.text = _root.players["object"+selected][7]
_root.yellow.text = _root.players["object"+selected][8]
_root.red.text = _root.players["object"+selected][9]
}
stop();

Jubba
September 22nd, 2003, 07:54 PM
its must be something to do with how your AS is grabbing the information but I can't see a stop to fix it. Just take a look at how your functions are structured and how you are outputting the data in Flash.