Im not satisfied im doing this the best way possible. Im taking serialized code from database column location. Im assuming that i have to implode the serialized data and then explode it because when i just use implode i cant access the entries in counties so i used explode. Im sure there's a better approach?
$adid = $_GET['id'];
$query = "SELECT * FROM ad WHERE id = '$adid'";
$data = mysqli_query($dbc, $query);
$ad = mysqli_fetch_array($data);
//retrieve serialized data containing county id's
$counties = explode(" ", implode(" ", unserialize($ad['location'])));
for ($i = 0; $i <= count($counties); $i++) {
echo getCounty($counties[$i]); //getCounty: enter county id and return county name
}
FYI: $ad['location'] = a:2:{i:0;s:1:"2";i:1;s:2:"20";}