Skip to content

Instantly share code, notes, and snippets.

@XxAnonimeKxX
Created May 8, 2020 14:13
Show Gist options
  • Select an option

  • Save XxAnonimeKxX/c876e8ae9b9fbae9756807db071d888d to your computer and use it in GitHub Desktop.

Select an option

Save XxAnonimeKxX/c876e8ae9b9fbae9756807db071d888d to your computer and use it in GitHub Desktop.
<?php
class db{
public $con;
public function __construct(){
$this->con = mysqli_connect("localhost", "root", "", "wakamegroup");
if(!$this->con){
echo 'failed '.mysqli_connect_error($this->con);
}
}
public function insert($table, $data){
$string = "INSERT INTO ".$table." (";
$string.= implode(",",array_keys($data)).') VALUES (';
$string .= "'" .implode("','",array_values($data))."')";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>sasdfdas</title>
<link rel="stylesheet" href="css/insert.css">
</head>
<body>
<?php
require_once "classes/db.php";
$data = new db;
$insert = array(
'p_name' => 'test',
'p_price' => 'test2'
);
echo $data->insert("products", $insert);
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment