* include('./I18N/Arabic.php'); * $obj = new I18N_Arabic('Query'); * * $dbuser = 'root'; * $dbpwd = ''; * $dbname = 'test'; * * try { * $dbh = new PDO('mysql:host=localhost;dbname='.$dbname, $dbuser, $dbpwd); * * // Set the error reporting attribute * $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); * * $dbh->exec("SET NAMES 'utf8'"); * * if ($_GET['keyword'] != '') { * $keyword = @$_GET['keyword']; * $keyword = str_replace('\"', '"', $keyword); * * $obj->setStrFields('headline'); * $obj->setMode($_GET['mode']); * * $strCondition = $Arabic->getWhereCondition($keyword); * } else { * $strCondition = '1'; * } * * $StrSQL = "SELECT `headline` FROM `aljazeera` WHERE $strCondition"; * * $i = 0; * foreach ($dbh->query($StrSQL) as $row) { * $headline = $row['headline']; * $i++; * if ($i % 2 == 0) { * $bg = "#f0f0f0"; * } else { * $bg = "#ffffff"; * } * echo "$headline"; * } * * // Close the databse connection * $dbh = null; * * } catch (PDOException $e) { * echo $e->getMessage(); * } *