# Getting vars from MySQL to Flash

**URL:** <https://forum.kirupa.com/t/getting-vars-from-mysql-to-flash/52585>\
**Category:** flash\
**Created:** [May 25, 2004, 1:46pm UTC](https://forum.kirupa.com/t/getting-vars-from-mysql-to-flash/52585 "2004-05-25T13:46:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kafir](https://avatars.discourse-cdn.com/v4/letter/k/e36b37/32.png) [@kafir](https://forum.kirupa.com/u/kafir)\
**Post date:** [May 25, 2004, 1:46pm UTC](https://forum.kirupa.com/t/getting-vars-from-mysql-to-flash/52585/1 "2004-05-25T13:46:29Z")

</div>

I have a MySQL database from where i need som info. presented in flash.

Here’s my PHP code. E.g. i need the info(vars) of $europePercentage to be presented in my movieclip in flash.

Can anyone help me with the AS (flash) code to make this possible?

Hope someone can help

/Kafir

\<?php

```
// start the session
session_start();

include ($_SERVER["DOCUMENT_ROOT"] . "/include.php");	
include_once ($GLOBALS['homeDir'] . "common/functions.php");

// check whether the user is logged in or not
//checkUserLogin();

// initalize vars
$europePercentage = $northAmericaPercentage = $southAmericaPercentage = $asiaPercentage = $africaPercentage = $australiaPercentage = 0;
	
// get each of the countries and set them
$sql = "SELECT cID AS id, cTitle AS title FROM tblCountry UNION SELECT coID AS id, coTitle AS title FROM tblContinent";
	
$result = mysql_query($sql)
	or die("error: " . mysql_error());

while($myRow = mysql_fetch_assoc($result))
{
	$$myRow['title'] = $myRow['id'];				
}	

// get the total number of residences
$sql = "SELECT COUNT(rID) AS cnt FROM tblRessidence";
	
$result = mysql_query($sql)
	or die("error: " . mysql_error());

while($myRow = mysql_fetch_assoc($result))
{
	$totalRes = $myRow['cnt'];				
}

// get residences pr. continent
$sql = "SELECT coTitle, COUNT(r_ciID) AS coCnt FROM tblContinent, tblCountry, tblRegion, tblCity, tblRessidence WHERE coID = c_coID AND cID = rg_cID AND rgID = ci_rgID AND ciID = r_ciID GROUP BY coTitle";
	
$result = mysql_query($sql)
	or die("error: " . mysql_error());

while($myRow = mysql_fetch_assoc($result))
{
	switch($myRow['coTitle'])
	{
		case "Europe": $europePercentage = ceil(($myRow['coCnt'] / $totalRes)*100); break;
		case "Asia": $asiaPercentage = ceil(($myRow['coCnt'] / $totalRes)*100); break;
		case "Africa": $africaPercentage = ceil(($myRow['coCnt'] / $totalRes)*100); break;
		case "North America": $northAmericaPercentage = ceil(($myRow['coCnt'] / $totalRes)*100); break;
		case "South America": $southAmericaPercentage = ceil(($myRow['coCnt'] / $totalRes)*100); break;
		case "Australia and Oceania": $australiaPercentage = ceil(($myRow['coCnt'] / $totalRes)*100); break;
	}				
}

print "Europe: " . $europePercentage . "&lt;BR&gt;";
print "Asia: " . $asiaPercentage . "&lt;BR&gt;";
print "Africa: " . $africaPercentage . "&lt;BR&gt;";
print "North America: " . $northAmericaPercentage . "&lt;BR&gt;";
print "South America: " . $southAmericaPercentage . "&lt;BR&gt;";
print "Australia and Oceania: " . $australiaPercentage . "&lt;BR&gt;";

```

?\>

**Getting vars from MySQL to Flash**
