Land

[insert_php]
//echo “Welcome to PHP”;

// database connection
$host = “localhost”;
$dbname = “shahzad_cbf”;
$user = “shahzad”;
$pw = “P(zxtgaH^W)?”;
try{
$pdo = new PDO(“mysql:host=$host;dbname=$dbname”, “$user”, “$pw”);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec(“SET NAMES ‘utf8′”);
//echo “

Connected to db – $dbname

“;
}catch(PDOException $e){
$error = “

Unable to connect to database.

“;
//include “includes/error.html.php”;
echo “

Unable to connect to db – $dbname

“;
exit();
}

//——————————–

try{
$sql = “SELECT `cbf_branch_id`, `cbf_branch_name`, `cbf_branch_description` FROM `cbf_branch` ORDER BY `cbf_branch_name`”;
$result = $pdo->query($sql);

}catch(PDOException $e){
$error = “Error fetching branches – “.$e->getMessage();
echo $error;
exit();
}
foreach($result as $row){
$branches[]= array(
‘id’=>$row[‘cbf_branch_id’],
‘name’=>$row[‘cbf_branch_name’],
‘desc’=>$row[‘cbf_branch_description’]
);
}

echo “

    “;
    foreach ($branches as $branch) {
    echo “
  1. “.$branch[‘name’].”:
    “.$branch[‘desc’].”
  2. “;
    }
    echo “

“;

[/insert_php]