Created
May 8, 2020 14:13
-
-
Save XxAnonimeKxX/c876e8ae9b9fbae9756807db071d888d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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))."')"; | |
| } | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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