php的print(SELECT)语句

I want to print (SELECT) statement by php . I have this code but it is not working with deferent language ( like Arabic ) ,

<?php 
include "connect.php" ;
mysql_query("set character_set_server='utf8'");
mysql_query("set names 'utf8'");
$sql = "SELECT * FROM appointment";
$result = mysql_query($sql) or die(mysql_error()); 
while($row = mysql_fetch_array($result)){ 
    echo "<br>";
    echo $row['id_file']; 
    echo "<br>";
    echo $row['clinic']; 
    echo "<br>";
    echo $row['date1']; 
    echo "<br>";
    echo $row['time']; 
    echo "<br> " ; 
}
?> 

You need to:

  • make sure that the php file is saved as utf-8 and not ANSI
  • add this after the opening php tag

    header('Content-Type: text/html; charset=utf-8');
    
  • make sure that the database table and its columns are using utf8_general_ci or similar collation (and the data is entered after the collation has been set)