PHP MYSQL

SAVE & LOAD TINYMCE CONTENT 

(quick guide & example)

SIMPLE CONTENTS TABLE id    | INTEGER PRIMARY text | TEXT NOT NULL

CONTENT DATABASE

01

HTML FORM <form method="post">   <textarea id="mce" name="t"></textarea>  </form>

SAVE CONTENT (PART A)

02

CONNECT TO DATABASE $pdo = new PDO( "mysql:host=HOST; dbname=NAME;charset=utf8",  USER, PASSWORD);

SAVE INTO DATABASE $stmt = $pdo->prepare("REPLACE INTO `contents` (`id`, `text`) VALUES (?,?)");  $stmt->execute([99, $_POST["t"]]);

SAVE CONTENT (PART B)

03

CONNECT TO DATABASE $pdo = new PDO( "mysql:host=HOST; dbname=NAME;charset=utf8",  USER, PASSWORD);

LOAD CONTENT FROM DATABASE

04

RETRIEVE FROM DATABASE $stmt = $pdo->prepare("SELECT `content` FROM `contents` WHERE `id`=?");  $stmt->execute([99]); echo $stmt->fetchColumn();