Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-27-2004, 11:39 AM   #21
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

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.
freddycodes is offline   Reply With Quote
Old 04-27-2004, 12:09 PM   #22
rubbersoul
Registered User
 
Join Date: Apr 2004
Posts: 28
Default

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
rubbersoul is offline   Reply With Quote
Old 04-27-2004, 01:36 PM   #23
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

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
======================
freddycodes is offline   Reply With Quote
Old 04-27-2004, 01:45 PM   #24
rubbersoul
Registered User
 
Join Date: Apr 2004
Posts: 28
Default

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!
rubbersoul is offline   Reply With Quote
Old 04-27-2004, 07:06 PM   #25
rubbersoul
Registered User
 
Join Date: Apr 2004
Posts: 28
Default

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.
Attached Files
File Type: zip code.zip (484 Bytes, 101 views)
rubbersoul is offline   Reply With Quote
Old 04-27-2004, 07:15 PM   #26
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

As soon as I get home I can show you how, but I can't from here.
freddycodes is offline   Reply With Quote
Old 04-27-2004, 08:36 PM   #27
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

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_HOSTMYSQL_USERMYSQL_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(
"&");
    } 
?>
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 04-27-2004, 09:14 PM   #28
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

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_HOSTMYSQL_USERMYSQL_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";
    }

?>
freddycodes is offline   Reply With Quote
Old 04-27-2004, 09:43 PM   #29
rubbersoul
Registered User
 
Join Date: Apr 2004
Posts: 28
Default

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
rubbersoul is offline   Reply With Quote
Old 04-27-2004, 09:53 PM   #30
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Can you dump your MySQL data and post it here???
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:02 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.