Example Code:
<?php
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Query');
echo $Arabic->allForms('فلسطينيون');
$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);
$Arabic->setStrFields('headline');
$Arabic->setMode($_GET['mode']);
$strCondition = $Arabic->getWhereCondition($keyword);
$strOrderBy = $Arabic->getOrderBy($keyword);
} else {
$strCondition = '1';
}
$StrSQL = "SELECT `headline` FROM `aljazeera` WHERE $strCondition ORDER BY $strOrderBy";
$i = 0;
foreach ($dbh->query($StrSQL) as $row) {
$headline = $row['headline'];
$i++;
if ($i % 2 == 0) {
$bg = "#f0f0f0";
} else {
$bg = "#ffffff";
}
echo"<tr bgcolor=\"$bg\"><td><font size=\"2\">$headline</font></td></tr>";
}
// Close the databse connection
$dbh = null;
} catch (PDOException $e) {
echo $e->getMessage();
}
Total execution time is 0.0010619163513184 seconds
Amount of memory allocated to this script is 376408 bytes
Names of included or required files:
- /var/www/vhosts/ar-php.org/httpdocs/I18N/Arabic/Examples/Query.php
Related Class Documentation