Members

[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 * FROM `cbf_civil_members`”;
$result = $pdo->query($sql);

}catch(PDOException $e){
$error = “Error fetching Civil Members data – “.$e->getMessage();
echo $error;
exit();
}
foreach($result as $row){
$members[]= array(
‘id’=>$row[‘id’],
‘name’=>$row[‘name’],
‘ward’=>$row[‘ward’],
‘party’=>$row[‘party’]
);
}

echo “

    “;
    foreach ($members as $member) {
    echo “
  1. “.$member[‘name’].”
    “;
    if(is_numeric($member[‘ward’])){echo “Ward -“;};

    echo ” “.$member[‘ward’].”
    Party – “.$member[‘party’].”

  2. “;
    }
    echo “

“;

[/insert_php]