Looking for a function
Posted: Fri Dec 02, 2005 2:33 pm
Is there any function that will take variables that are generated by a sql query and return the one that has the highest numerical value?
for instance, i have these variables:
each of them has a numerical value, and i want it to do something like the max() function, but i want it to return the name of the variable as well? Is that even possible?
for instance, i have these variables:
Code: Select all
<?php
$conn = mysql_connect("localhost", "root", "");
mysql_select_db("countries", $conn);
$result = mysql_query("SELECT UnitedStates, GreatBritain, France, Spain, Nicaragua, Hawaii, Panama, Jamaica, Sudan, Libya, India, Algeria, Vietnam, CostaRica, Philippines, China, PuertoRico, Cuba FROM forts WHERE Country = '$ID'")
or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
$USF = $row['UnitedStates'];
$GRF = $row['GreatBritain'];
$FRF = $row['France'];
$SPF = $row['Spain'];
$NIF = $row['Nicaragua'];
$HAF = $row['Hawaii'];
$PAF = $row['Panama'];
$JAF = $row['Jamaica'];
$SUF = $row['Sudan'];
$LIF = $row['Libya'];
$INF = $row['India'];
$ALF = $row['Algeria'];
$VIF = $row['Vietnam'];
$COF = $row['CostaRica'];
$PHF = $row['Philippines'];
$CHF = $row['China'];
$PUF = $row['PuertoRico'];
$CUF = $row['Cuba'];
}
?>