<?php
class Sql{
public $con;
private $host="localhost";
private $user="root";
private $password="";
private $db="store";
public $sq;
public function DbCoect()//for conecting to data base
{
$this->con=mysqli_coect($this->host,$this->user,$this->password,$this->db);
mysqli_query($this->con,"SET NAMES 'utf8'");
}
public function GetQuery($query)//for execute query
{
$this->sq=mysqli_query($this->con,"$query")or die(mysqli_error($this->con));
}
public function ShowResult()//for perform result in a table
{
while($row=mysqli_fetch_assoc($this->sq))
{
echo"<tr>";
foreach($row as $val)
{
echo"<td>$val</td>";
}
echo"</tr>";
}
}
}
?>
<?php
include("config.php");
$conect=new Sql();
$q="SELECT * FROM celler";
$conect->GetQuery($q);
echo"<table>";
$conect->ShowResult();
echo"</table>";
?>
برچسب: استفاده,
نویسنده: خنج