$DATABASE->select_sql('SELECT * FROM owner WHERE population_id= '.$id_population.' ');
if( count( $DATABASE->dataresult ) > 0 ) {
foreach($DATABASE->dataresult as $result) {
$populationID = $result['population_id'];
$DATABASE->select_sql('SELECT * FROM permit WHERE population_id="'.$populationID.'"');
foreach($DATABASE->dataresult as $result_1);
$permitTypeID = $result_1['permit_type_id'];
$permitResiveNO = $result_1['permit_recieve_no'];
$issuedToDate = $result_1['issued_to_date'];
$controlName = $result_1['control_name'];
$calculateName = $result_1['calculate_name'];
$amountDate = $result_1['amount_date'];
$DATABASE->select_sql('SELECT * FROM permit_type WHERE permit_type_id="'.$permitTypeID.'"');
foreach($DATABASE->dataresult as $result_2);
$DATABASE->select_sql('SELECT * FROM building WHERE population_id="'.$populationID.'"');
foreach($DATABASE->dataresult as $result_3);
$DATABASE->select_sql('SELECT * FROM land WHERE population_id="'.$populationID.'"');
foreach($DATABASE->dataresult as $result_4);
$DATABASE->select_sql('SELECT * FROM sys_tambon WHERE tambon_id="'.$result_4['tambon_id'].'"');
foreach($DATABASE->dataresult as $result_5);
$DATABASE->select_sql('SELECT * FROM road_table WHERE road_id="'.$result_4['road_id'].'"');
foreach($DATABASE->dataresult as $result_6);
$DATABASE->select_sql('SELECT * FROM soi_table WHERE soi_id="'.$result_4['soi_id'].'"');
foreach($DATABASE->dataresult as $result_7);
$DATABASE->select_sql('SELECT * FROM doc_attach WHERE population_id="'.$populationID.'"');
foreach($DATABASE->dataresult as $result_8);
}