Location: PHPKode > scripts > Arabic MySQL Query > arabic-mysql-query/example.php
<?php

include_once('arquery.class.php');
mysql_connect('localhost','root','');
mysql_select_db('test');

if (isset($_POST['keyword'])) {
    if($keyword != ''){
        $keyword = @$_POST['keyword'];
        $keyword = str_replace('\"', '"', $keyword);

        $obj = new ArQuery();
        $obj->setStrFields('headline,date');
        $obj->setMode($_POST['mode']);

        $strCondition = $obj->getWhereCondition($keyword);
    }else{
        $strCondition = '1';
    }

    $StrSQL = "SELECT headline, date FROM aljazeera WHERE $strCondition ORDER BY BINARY headline DESC";
    $rs = mysql_query($StrSQL);
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Arabic Query Class</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
</head>
<body dir="rtl">
    <font face="Tahoma" size="2">
    <table border="0" width="100%" dir="ltr">
      <tr>
        <td align="center">
          <a href="www.aljazeera.net" target=_blank><img src="images/Aljazeeralogo.gif" border="0"></a>
        </td>
      <tr>
      </tr>
        <td align="center">
          <font face="Tahoma" size="2">Example database table contains 574 headline from
          <a href="www.aljazeera.net" target=_blank>Aljazeera.net</a>
          news channel website presented at 2003.</font>
        </td>
      </tr>
    </table><hr />
    <form action="example.php" method="POST" name="search">
        ÅÈÍË Úä (Search for): <input type="text" name="keyword"> <input type="submit" value="ÈÍË (Go)" name="submit" /><br />
        <blockquote><blockquote><blockquote>
            <input type="radio" name="mode" value="0" checked /> Ãí ãä ÇáßáãÇÊ (Any word)
            <input type="radio" name="mode" value="1" /> ßá ÇáßáãÇÊ (All words)
        </blockquote></blockquote></blockquote>
    </form>

<?php if (isset($_POST['keyword'])) { ?>

    <hr />
    ÕíÛÉ ÇáÅÓÊÚáÇã <span dir="ltr">(SQL Query Statement)</span>
    <br /><textarea dir="ltr" align="left" cols="120" rows="4"><?php echo $StrSQL; ?></textarea><hr />

    äÊÇÆÌ ÇáÈÍË Úä (Search for) <b><?php echo $keyword; ?></b>:<br />
    <table cellpadding="5" cellspacing="2" align="center">
        <tr>
            <td bgcolor="#004488" align="center"><font color="#ffffff" size="2"><b>ÇáÎÈÑ ßãÇ æÑÏ Ýí ãæÞÚ ÇáÌÒíÑÉ<br />Headline at Aljazeera.net</b></font></td>
            <td bgcolor="#004488" align="center"><font color="#ffffff" size="2"><b>ÊÇÑíÎ äÔÑ ÇáÎÈÑ<br />Publishing date</b></font></td>
        </tr>
            <?php
            $i = 0;
            while ($row = mysql_fetch_assoc($rs)){
                $headline = $row['headline'];
                $date	  = $row['date'];
                $i++; if($i % 2 == 0){ $bg = "#f0f0f0"; }else{ $bg = "#ffffff"; }
                echo "<tr bgcolor=\"$bg\"><td><font size=\"2\">$headline</font></td>
                      <td align=\"center\"><font size=\"2\">$date</font></td></tr>";
            }
            ?>
    </table>
<?php } ?>
</font>
</body>
</html>
Return current item: Arabic MySQL Query