I have a country, state, city cascading dropdown which I used in add property and edit property pages. The country table has columns : country\_id and country\_name. 

Now when I want to load values into the edit page, I want to convert the country\_id into country\_name to show in the dropdown. I am already able to do this using the following code:

```
<?php   
$country_id = $data['property_country'];
$select = $con->prepare("SELECT country_name from tbl_country where country_id='$country_id'");
$select->setFetchMode(PDO::FETCH_ASSOC);
$select->execute();
$data2 = $select->fetchAll();
foreach ($data2 as $row1) {
    echo $row1['country_name'];
}
?>

```

However since this function will be used at multiple location I would like to make a function or a class and call it. Can someone help me.