PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table posts ( id int auto_increment primary key, title varchar(255), date date, author varchar(255), content text, image varchar(255) );
Copy Clear
Copy Format Clear
<?php $connect = &$pdo; $title = 'title'; $date = date('Y-m-d'); $author = 'New author'; $content = 'Some interesting content'; $fileNameNew = 'file.txt'; $query = $connect->prepare("insert into posts (title,date,author,content,image) values(?, ?, ?, ?, ?);"); if($query->execute([$title,$date,$author,$content,$fileNameNew])){ echo("POST UPLOADED SUCESSFULLY\n"); }else{ echo("POST UPLOADED HAS FAILED\n"); } $query = "SELECT * FROM posts;"; $stmt = $pdo->prepare($query); $stmt->execute(); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); print_r($posts);
Show:  
Copy Clear