04-27-2004, 11:39 AM
|
#21
|
|
Master of Nothing
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
|
Yes its very simple to do this, but like CyanBlue said you need to get your result in a format that flash can read.
Code:
Connected to mysql server localhost as user root
Database stats selected for use.
This is not a format that flash can read, well I take that back it is a format that flash can read by not very easily.
Now how many fields do you want to return to the flash movie? By fields, I mean how many things do you want to return.
|
|
|
04-27-2004, 12:09 PM
|
#22
|
|
Registered User
Join Date: Apr 2004
Posts: 28
|
Well myslq table is set up with the following fields:
name
games
goals
assists
total
penalty
I want all the data in that whole table to be diaplayed in one dynamic text field. i.e.
name games goals assists total penalty
John Doe 5 5 10 20 3
|
|
|
04-27-2004, 01:36 PM
|
#23
|
|
Master of Nothing
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
|
So will there be more than one entry in the table? Do you want it in a tabular format, formatting text like that is fairly difficult to do in a dynamic textfield?
Or something like
Name: John Doe
Games: 5
Goals: 5
Assists: 10
Total: 20
Penalty: 3
======================
Name: John Smith
Games: 3
Goals: 7
Assists: 10
Total: 20
Penalty: 5
======================
|
|
|
04-27-2004, 01:45 PM
|
#24
|
|
Registered User
Join Date: Apr 2004
Posts: 28
|
That would be fine....as long as I can have them ordered by Highest point person. I know I have to do this in mysql query....something like SELECT * from Players WHERE soething DESC.....but as for formating purposes.....I don't really care!
|
|
|
04-27-2004, 07:06 PM
|
#25
|
|
Registered User
Join Date: Apr 2004
Posts: 28
|
OK.....Cyan, I commented out what you asked and I added the line that Jerry Script mentioned to add....but everyone keeps mentioning that I have to put my php in a format that flash will read....so how do I do that? What is the code? I've include my php file again with the changes.
|
|
|
04-27-2004, 07:15 PM
|
#26
|
|
Master of Nothing
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
|
As soon as I get home I can show you how, but I can't from here.
|
|
|
04-27-2004, 08:36 PM
|
#27
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Um... Not sure how accurate it is going to be, but you could try this...(I am sure freddycodes will be coming up with whole lot better script for that...  )
PHP Code:
<?php
//Set up constants
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', '***');
define ('MYSQL_DB', 'stats');
//If we fail to connect
if (! mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) )
{
die('Failed to connect to host "' . MYSQL_HOST . '".');
}
mysql_select_db(MYSQL_DB);
//Select entire table
$result = mysql_query('SELECT * FROM players');
$result = str_replace("\\n","&",$result);
$num_record = mysql_num_rows($result);
$num_row = mysql_num_fields($result);
while ($row = mysql_fetch_row($result))
{
for($column_num = 0; $column_num < $num_row; $column_num++)
{
$column_name = mysql_field_name($result, $column_num);
echo "$column_name$i=$row[$column_num]";
}
echo("&");
}
?>
|
|
|
04-27-2004, 09:14 PM
|
#28
|
|
Master of Nothing
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
|
No time to explain now, but here is a sample
Code:
var data = [];
lv = new LoadVars();
lv.load("http://localhost:8080/GetData.php");
lv.onData = function(raw)
{
var delim = (raw.indexOf("\r\n") > -1) ? "\r\n" : (raw.indexOf("\r") > -1) ? "\r" : "\n";
var temp = raw.split(delim);
var fields = temp.shift().split("||");
for(var i=0;i<temp.length;i++)
{
var row = temp[i].split("||");
if(row.length != fields.length) continue;
var tmpObj = {};
for(var j=0;j<row.length;j++)
{
tmpObj[fields[j]] = row[j];
}
data.push(tmpObj);
}
displayText();
}
function displayText()
{
var msg = "";
for(var i=0;i<data.length;i++)
{
for(var x in data[i])
{
msg += x + ": " + data[i][x] + "\n";
}
msg += "==========================\n";
}
tbArticles.text = msg;
}
PHP
PHP Code:
<?php
//Set up constants
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', '');
define ('MYSQL_DB', 'venues');
//If we fail to connect
if (! mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) )
{
die('Error"' . MYSQL_HOST . '".');
}
mysql_select_db(MYSQL_DB);
//Select entire table
$result = mysql_query('SELECT * FROM articles');
$num_row = mysql_num_fields($result);
for($j=0;$j<$num_row;$j++)
{
$field = mysql_fetch_field($result, $j);
$fields[] = $field->name;
}
//Print the fields
print implode($fields, "||")."\n";
while($row = mysql_fetch_assoc($result))
{
print implode($row, "||")."\n";
}
?>
|
|
|
04-27-2004, 09:43 PM
|
#29
|
|
Registered User
Join Date: Apr 2004
Posts: 28
|
Hey freddy,
Thanks for the attempt but it seems nothing is working for me...I tried your code and at first I got a syntax error....you were missing a }......then after fixing that I get nothing....no errors....no data, and I also can't see in your PHP where you did the &variable =$variable conversion.....so once again
|
|
|
04-27-2004, 09:53 PM
|
#30
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Can you dump your MySQL data and post it here???
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 01:30 AM.
///
|
|