I haven't been working very much with arrays before, do I'm pretty clueless of how to do this. Hope someone have the time to help out.
I have the following code;
What I need to do, is for the php script to loop through the srvCount and compare which system has the lowest amount of active servers ($sysC), and then echo something like terra=2=27 ($sysN."=".$sys ID."=".$sysC)
Hope you understand what I mean.
I have the following code;
Code:
<?php
function check_system($sys)
{
$srvCount;
$con = mysql_connect("localhost","username","passwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Systems", $con);
foreach( $sys as $sysName => $sysID)
{
$result = mysql_query("SELECT COUNT(system_id) FROM cc_servers WHERE system_id = $sysID");
while($row = mysql_fetch_array($result))
{
$srvCount[$sysName] = $row['COUNT(system_id)'];
}
}
}
$auth = "dfnadbf08GA5G";
$loc = $_GET["loc"];
$USsystem = array("terra"=>2, "tellus"=>3);
$EUsystem = array("gaia"=>1);
if ( $auth == $_GET["auth"] )
{
if($loc == USA)
{
$system = $USsystem;
check_system($system);
}
else if($loc == "EU")
{
$system = $EUsystem;
check_system($system);
}
}
else
{
die('Wrong Authorization code');
}
?>
Hope you understand what I mean.
Comment