Ok thanks for the reply but that echo is not returning what we need.
Now as you can see when we did the print_r() the result we get is:
Array ( [14] => Array ( [CountryId] => 14 [Country] => Australia [FIPS104] => AS [ISO2] => AU [ISO3] => AUS [ISON] => 36 [Internet] => AU [Capital] => Canberra [MapReference] => Oceania [NationalitySingular] => Australian [NationalityPlural] => Australians [Currency] => Australian dollar [CurrencyCode] => AUD [Population] => 19357594 [Title] => Australia [measurement] => metric [Comment] => ISO includes Ashmore and Cartier Islands,Coral Sea Islands [sortOrder] => 1 ) )
Did you notice here that we have 14 in the beginning whereas it should begin with [0].
And we are using this function by the way to get this:
$VisitorCountryID = filter_countries(array('Country' => $_SESSION['UserCountryName']));
I believe there is something with the function. (normally this function would accept accept as countryID but in our case we have the country Name and to our surprise, it does return the country info array but perhaps not in the proper forms.
Therefore here is the function definition, it is little intimidating
and here it is:
function filter_countries($args=array())
{
global $connection;
global $GLOBAL_DATABASE;
$selectFields = (is_null($args['selectFields'])) ? ' * ' : ((is_array($args['selectFields'])) ? implode(',', $args['selectFields']) : "$args[selectFields]");
$limit = (isset($args['limit'])) ? " LIMIT $args[limit] " : ' ';
$order = (isset($args['orderby'])) ? " ORDER BY $args[orderby] " : ' ';
$unique = array('CountryId');
$fields = array( 'FIPS104', 'ISO2', 'ISO3', 'ISON', 'Internet', 'Capital', 'MapReference', 'NationalitySingular', 'NationalityPlural', 'Currency', 'CurrencyCode', 'Title', 'Comment');
foreach ($fields as $f)
if (isset($args[$f]))
$sql .= " AND `$f` LIKE '%$args[$f]%' ";
$exactfields = array('Country', 'CountryId');
foreach ($exactfields as $f)
{
if (isset($args[$f . ' ne']))
$sql .= " AND `$f` != '" . $args[$f . ' ne'] . "' ";
if (isset($args[$f . ' lt']))
$sql .= " AND `$f` < '" . $args[$f . ' lt'] . "' ";
if (isset($args[$f . ' lte']))
$sql .= " AND `$f` <= '" . $args[$f . ' lte'] . "' ";
if (isset($args[$f . ' gt']))
$sql .= " AND `$f` > '" . $args[$f . ' gt'] . "' ";
if (isset($args[$f . ' gte']))
$sql .= " AND `$f` >= '" . $args[$f . ' gte'] . "' ";
if (isset($args[$f]))
$sql .= " AND `$f` = '" . $args[$f] . "' ";
}
$numberfields = array( 'Population', 'sortOrder');
foreach ($numberfields as $f)
{
if (isset($args[$f . ' ne']))
$sql .= " AND `$f` != '" . $args[$f . ' ne'] . "' ";
if (isset($args[$f . ' lt']))
$sql .= " AND `$f` < '" . $args[$f . ' lt'] . "' ";
if (isset($args[$f . ' lte']))
$sql .= " AND `$f` <= '" . $args[$f . ' lte'] . "' ";
if (isset($args[$f . ' gt']))
$sql .= " AND `$f` > '" . $args[$f . ' gt'] . "' ";
if (isset($args[$f . ' gte']))
$sql .= " AND `$f` >= '" . $args[$f . ' gte'] . "' ";
if (isset($args[$f]))
$sql .= " AND `$f` = '" . $args[$f] . "' ";
}
$datefields = array();
foreach ($datefields as $f)
{
if (isset($args[$f . ' ne']))
$sql .= " AND `$f` != '" . $args[$f . ' ne'] . "' ";
if (isset($args[$f . ' lt']))
$sql .= " AND `$f` < '" . $args[$f . ' lt'] . "' ";
if (isset($args[$f . ' lte']))
$sql .= " AND `$f` <= '" . $args[$f . ' lte'] . "' ";
if (isset($args[$f . ' gt']))
$sql .= " AND `$f` > '" . $args[$f . ' gt'] . "' ";
if (isset($args[$f . ' gte']))
$sql .= " AND `$f` >= '" . $args[$f . ' gte'] . "' ";
if (isset($args[$f]))
$sql .= " AND `$f` LIKE '%" . $args[$f] . "%' ";
}
$select = "select $selectFields from `$GLOBAL_DATABASE`.`Countries` WHERE 1 $sql $order $limit";
if ($args['verbose'] == true)
echo $select;
if (!$result = mysql_query($select, $connection))
return false;
$return = array();
while ($row = mysql_fetch_assoc($result))
{
if (file_exists(BASE_DIR . "images/flags/" . strtolower($row['ISO2']) . ".gif"))
{
$row['imageLink'] = "/images/flags/" . strtolower($row['ISO2']) . ".gif";
}
$return[$row['CountryId']] = $row;
}
if ($args['limit'] == 1 || check_if_exists($args, $unique))
return current($return);
return $return;
}
What change we need to make in the function definition to get the right info back when the country name is passed to it 