PHP 中的阿拉伯文文本未从 TextBoX 中搜索到

Arabic Text in PHP not searched from TextBoX

下面的代码根据在文本框中输入的员工编号或名字搜索员工,但我的名字是阿拉伯语,但不匹配。所附图片在 broser 上显示为阿拉伯语,但不是通过文本框搜索我不知道为什么

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <html> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <head> 
        <meta  http-equiv="Content-Type" content="text/html;  charset=iso-8859-1"> 
        <title>Search  Contacts</title> 
        <link rel="stylesheet" href="css/insert.css" /> 
        <link rel="stylesheet" href="css/navcss.css" />
      </head> 
      <body> 
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <div class="maindiv">
<?php include("includes/head.php");?>
<?php include("menu.php");?>

        <!--HTML form -->
            <div class="form_div">
        <h3>Search  Records:</h3> 
        <p>You  may search by Employee Number</p> 
        <form  method="post" action="search.php?go"  id="searchform"> 
          <input  type="text" class="input" name="emp_number"> 
          <input  type="submit" class="input" name="submit" value="Search"> 
        </form>

<?php 

include 'connect-db.php';
    //do  something here in code 

      if(isset($_POST['submit'])){ 
      if(isset($_GET['go'])){ 
      if(preg_match("/^[a-zA-Z0-9,]+$/", $_POST['emp_number'])){ 
      //if(preg_match("/\p{Arabic}/u", $_POST['first_name'])){
      $emp_number=$_POST['emp_number']; 
      //$first_name=$_POST['first_name']; 
      //connect  to the database 
      //$db=mysql_connect  ("localhost", "root",  "") or die ('I cannot connect to the database  because: ' . mysql_error()); 
      //-select  the database to use 
      //$mydb=mysql_select_db("mydb"); 
      //-query  the database table 
      //mysqli_query($connection,"SET CHARACTER SET utf8");
      $sql="SELECT  * FROM employees WHERE emp_number LIKE '%" . $emp_number .  "%' OR first_name LIKE '%" . $emp_number."%'"; 
      //-run  the query against the mysql query function . $name .
      $result=mysql_query($sql); 
      //-create  while loop and loop through result set 
      while($row=mysql_fetch_array($result)){ 
              $FirstName  =$row['first_name'];

       echo "<table border='1' cellpadding='10'>";
       echo "<tr><th>First Name</th> <th>Last Name</th><th>Employee Number</th><th>Department</th><th>Email</th><th>Total Printers</th><th>Total Scanners</th><th>Total PCs</th><th>Total Telephones</th></tr>";        

      //-display the result of the array 
      echo "<tr>";
      echo '<td>' . $row['first_name'] . '</td>';
      echo '<td>' . $row['last_name'] . '</td>';
      echo '<td>' . $row['emp_number'] . '</td>';
      echo '<td>' . $row['department'] . '</td>';
      echo '<td>' . $row['email'] . '</td>';
      echo '<td>' . $row['total_printers'] . '</td>';
      echo '<td>' . $row['total_scanners'] . '</td>';
      echo '<td>' . $row['total_pc'] . '</td>';
      echo '<td>' . $row['total_phones'] . '</td>';
      echo '<td class="forscreen"><a href="view-one.php?emp_id=' . $row['emp_id'] . '">View</a></td>'; 
      echo '<td class="forscreen"><a href="edit.php?emp_id=' . $row['emp_id'] . '">Edit</a></td>'; 
      echo '<td class="forscreen"><a href="delete4msearch.php?emp_id=' .$row['emp_id'] . '">Delete</a></td>'; 
      echo '<td class="forscreen"><a href="view-aceessory.php?emp_number=' .$row['emp_number'] . '">View Accessories</a></td>';
      echo '<td class="forscreen"><a href="equipments.php?emp_number=' .$row['emp_number'] . '">Add Accessories</a></td>';
      //echo '<button class="btnPrint" type="submit" value="Submit" onclick="window.print()">Print</button>';
      //echo '<button class="btnPrevious" type="submit" value="Submit" onclick="history.back(); return false;">Return to previous page</button>';


      /*echo "<ul>\n"; 
      echo "<li>" . "<a  href=\"search.php?first_name=$FirstName\">"   .$FirstName . "</a></li>\n"; 
      echo "</ul>"; */
      echo "</tr>";

      } 
      // close table>

echo "</table>";

      } 
      else{ 
      echo  "<p>Please enter a search query</p>"; 
      } 
      }

      }


    ?>  

    <div class="forscreen">
    <br />

<button class="btnPrint" type="submit" value="Submit" onclick="window.print()">Print</button>
<button class="btnPrevious" type="submit" value="Submit" onclick="history.back(); return false;">Return to previous page</button>

</div>


</div>
</div>  
      </body> 
    </html> 

现代版本的 PHP 可能不需要这样做,但在文件的第一行添加以下内容:

<?php
    header('Content-Type: text/html; charset=utf-8');
    mb_internal_encoding('UTF-8');
    mb_http_output('UTF-8');
?>

您应该检查数据库表的默认排序规则。我经常与韩国角色一起工作,我总是确保一切都设置为 utf8。 (HTML / PHP headers 和数据库表整理)。