<?php include('database_connection.php');

if(isset($_GET['CardNumber']))
{
//	$CardNumber=$_GET['CardNumber'];
}
else
{
	
}	
$serverName = "DESKTOP-6MOGENU\SQLEXPRESS";  
  
/* Connect using Windows Authentication. */  
try  
{  
$conn = new PDO( "sqlsrv:server=$serverName ; Database=mutakamela", "sa", "hamabd");  
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
//echo "done";
}  
catch(Exception $e)  
{   
die( print_r( $e->getMessage() ) );   
}  
  
/*$serverName = "DESKTOP-6MOGENU\SQLEXPRESS"; //serverName\instanceName
$connectionInfo = array( "Database"=>"mutakamela", "UID"=>"sa", "PWD"=>"hamabd");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}*/

  // Send a raw HTTP header
  header ('Content-Type: text/html; charset=UTF-8');
  
  // Declare encoding META tag, it causes browser to load the UTF-8 charset before displaying the page.
  echo '<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />';
  
  // Right to Left issue
 // echo '<body dir="rtl">';
//odbc_connect(dsn, user, password)
$sql="Select name,cast(Additionalinfo5 as nvarchar) as arabic from inventory where id=3262";

$result=$conn->query($sql);
$rows = $result->fetchAll(PDO::FETCH_NAMED);//FETCH_NUM

foreach($rows as $row) {

    printf($row['name']."-".$row['arabic']." \n");
}
//$row=$conn->mssql_fetch_array(result)($result);
//print_r($result->fetch_array());
$str="واللغة العربية PHP مشروع";
 // echo $str = iconv('cp1256', 'utf-8', $str);

//echo iconv("UTF-8", "cp1256", $row['arabic']);
/*$result=odbc_exec($connection,$sql);
while($row=odbc_fetch_array($result))
{
//	echo $row['arabic'];
	echo iconv("UTF-8", "cp1256", $row['arabic']);
	//print_r($row);
	//$id=$row['MemberID'];
	//$CardNumber=$row['CardNumber'];
	//if($CardNumber!="")
	//$newcard=getCardCode($CardNumber);
	//$sqlupdate="update pos_membersetup set CardNumber='$newcard' where memberid=$id";
	//odbc_exec($connection,$sqlupdate);

}*/
//phpinfo();
?>