Flash gurus, please help!

luv2liv

Diamond Member
Dec 27, 2001
3,505
95
91
How would you put this php script into a flash swf file?
Basically, the script logs onto the server and pulls the schedule and outputs it into a table. The result can be seen here

I know Flash cant just display a php file. Have been searching on google but maybe I haven?t search with the right keyword. Any advice?

The php code is:
===========

<?
$connection = mysql_connect("localhost","x","x");

if (!$connection)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}

$db = mysql_select_db("verge", $connection);

$today = date(D);

$sql = mysql_query("SELECT * FROM `daily` where day='".$today."' ORDER BY 'mil_time' ASC");

$num_results = mysql_num_rows($sql);

if ($num_results<>0)
{
echo "<table align=center width=223 cellpadding=0 cellspacing=5 border=0 class=todaycontent>";

while ($row = mysql_fetch_array($sql)) {
$field1 = $row["time"];
$field2 = $row["classes"];
$field3 = $row["teacher"];
echo "<tr><td width=55>$field1<td>$field2<td>$field3</td></tr>";
}

echo "</table>"; }
?>
 

Thyme

Platinum Member
Nov 30, 2000
2,330
0
0
There may be an HTML control in Flash (I haven't worked with it recently to know), but that's not really what you want. Best case using that is you have a flash box on a site that just looks like there is no flash there at all. If that's what you want, then why use Flash?

If you want to pull in tabular data from a PHP script then use fancy Flash controls to render it in a pretty way or add dynamism too complicated for JS, then that you can do. Last time I used Flash, you could load an arbitrary site and get the data from it. I suspect now you can use AJAX within Flash and just get your table as a JSON object or whatnot.
 

Drakkon

Diamond Member
Aug 14, 2001
8,401
1
0
Well for starters flash can't create tables using HTML. You can use that same PHP code and have flash connect to it using XML however.
Create a new XML Object
Load PHP page into XML object
Traverse XML object for each row loading it into 'movieclip' rows or into a table component
Heres a good AS@ doc on it (requires flash pro)
http://livedocs.adobe.com/flas...004&file=00000455.html
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
That PHP code needs to run on the server (not on the client) to make mySQL calls.

So like Drakkon says the Flash object needs to make a HTML or XML request to a script page running on the server, that returns data, then the Flash object displays the data.

Flash doesn't have built-in HTML table support but a textarea can use tab stops to create a similar effect with some text data. So if you don't want to use movie clips or table component you could have the server script page return tab-separated data.
 

luv2liv

Diamond Member
Dec 27, 2001
3,505
95
91
you're right, xml is the way to go.
i followed this video exactly and it worked on the first try!
http://library.creativecow.net...elow_lee/php_mysql.php
thanks everyone!

so this is the equivalent result i have
http://www.vergepoweryoga.com/new/

i pulled the data into flash via XML. it is a list now. would be nice if it was in a table format like the old one.... or if that list is not user selectable... because it is weird that an user can select an item from the list but it doesnt do anything. by the way, im not a coder.. i loathe coding!
 

Thyme

Platinum Member
Nov 30, 2000
2,330
0
0
Yeah I'm clicking the table and confused by it selecting. Probably should change that before you go live.