<?php
/**
*
*/
class CRUDuser{
        var $conn ;   
     function __construct()
    {
    $this->conn = new mysqli('localhost','root','root','simdes')or die($this->conn->error);
     }

function insert($table, $row = null){
    $sql = "INSERT INTO $table";
    $rows = null;
    $nilai = null;

foreach ($row as $key => $nilai) {
    $rows .=",".$key;
    $value .=",'".$nilai."'";}

    $sql .= "(".substr($rows, 1).")";
    $sql .= "VALUES(".substr($value, 1).")";
    echo $sql;
$simpan = $this->conn->query($sql) or die ($this->error);
$simpan = $this->conn->close();
if ($simpan) {    echo "berhasil menyimpan";
}else{
    echo "gagal menyimpan";
}
}

function fect($table,$where= null){
 $sql = "SELECT * FROM $table ";
 if ($where != null) {
     $sql .= "WHERE $where";
 }
$query = $this->conn->query($sql) or die($this->conn->error);

while ($rows = $query->fetch_array(MYSQLI_ASSOC))
    $data[] = $rows ;
      
return $data; 
}


}

?>



SEJARAH DAN KELEBIHAN VISUAL STUDIO

  SEJARAH VISUAL STUDIO. NET Microsoft Visual Studio merupakan sebuah perangkat lunak lengkap (suite) yang dapat digunakan untuk melakukan...

Popular Posts