<?php
try{
$conn = new PDO('mysql:host=127.0.0.1;dbname=todo', 'root', '');
} catch( PDOException $e){
echo 'khob jotil';
}
function insertTodo($data){
global $conn;
$sql = "INSERT INTO `task`(`name`) VALUES (:title)";
$stmt = $conn->prepare($sql);
return $stmt->execute(array(
':title' => $data
));
}
function readData($table = 'task', $done = 0){
global $conn;
$sql = "SELECT * FROM $table";
$res = $conn->query($sql);
return $res->fetchAll();
}
?>