Example Output:

Example database table contains 574 headline from Aljazeera.net news channel website presented at 2003.

إبحث عن (Search for): (مثال: فلسطينيون)
أي من الكلمات (Any word) كل الكلمات (All words)

صيغة الإستعلام (SQL Query Statement)

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.00021505355834961 seconds
Amount of memory allocated to this script is 366288 bytes

Names of included or required files:

Related Class Documentation