PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Khaled Al-Shamaa   Arabic MySQL Query   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Arabic MySQL Query
Build SQL queries considering Arabic lexical rules
Author: By
Last change: Implement Mr. Saleh AlMatrafe <saleh@saleh.cc> update on ArQuery class by using "CASE WHEN" statement in ORDER BY section for more relevant ordering.
Date: 16 years ago
Size: 4,773 bytes
 

Contents

Class file image Download
<?php
@ini_set('zend.ze1_compatibility_mode', '1');

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

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

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

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

   
$StrSQL =
       
"SELECT headline FROM aljazeera WHERE $strCondition";
   
$rs = mysql_query($StrSQL);
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=windows-1256" />

<meta name="Subject" content="Arabic Query Class" />
<meta name="Description" content="Arabic Query Class" />
<meta name="Classification" content="PHP and Arabic Language" />
<meta name="Keywords" content="MySQL, SQL, Query, Stem, Search, PHP, Arabic, Language, Development, Implementation, Open Source, Free, GPL, Classes, Code" />
<meta name="Language" content="English, Arabic" />
<meta name="Author" content="Khaled Al-Shamaa" />
<meta name="Copyright" content="Khaled Al-Shamaa" />
<meta name="Designer" content="Khaled Al-Shamaa" />
<meta name="Publisher" content="Khaled Al-Shamaa" />
<meta name="Distribution" content="Global" />
<meta name="Robots" content="INDEX,FOLLOW" />
<meta name="City" content="Aleppo" />
<meta name="Country" content="Syria" />

<link rel="shortcut icon" href="../favicon.ico" />
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<title>Arabic Query Class</title>
</head>

<body>

<center>
<div style="width: 80%; position:absolute; left:10%; top:0%; z-index:1">
<br />
<div class="tabArea" align="center">
  <a class="tab" href="example.php">Example</a>
  <a class="tab" href="about.html">About</a>
  <a class="tab" href="http://www.ar-php.com">Homepage</a>
</div>

<div class="Paragraph" dir="rtl">

    <font face="Tahoma" size="2">
    <table border="0" width="100%" dir="ltr">
      <tr>
        <td align="center">
          <a href="http://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="http://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="80" rows="4"><?php echo $StrSQL; ?></textarea><hr />

    نتائج البحث عن (Search for) <b><?php echo $keyword; ?></b>:<br />
    <table cellpadding="5" cellspacing="2" align="center" width="80%">
        <tr>
            <td bgcolor="#004488" align="center"><font color="#ffffff" size="2"><b>الخبر كما ورد في موقع الجزيرة<br />Headline at Aljazeera.net</b></font></td>
        </tr>
            <?php
$i
= 0;
while (
$row = mysql_fetch_assoc($rs)) {
   
$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>";
}

?>
</table>
<?php } ?>
</font>

</div>

<table border="0" cellspacing="0" align="left">
  <tr>
    <td bgcolor="#448800">&nbsp;&nbsp;</td>
    <td bgcolor="#66aa00">&nbsp;&nbsp;</td>
    <td bgcolor="#77bb00">&nbsp;&nbsp;</td>
    <td bgcolor="#aadd00">&nbsp;&nbsp;</td>
    <td bgcolor="#eeff66">&nbsp;&nbsp;</td>
  </tr>
</table>

</div>
</center>
          <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
          </script>
          <script type="text/javascript">
          _uacct = "UA-1268287-1";
          urchinTracker();
          </script>
</body>
</html>