PHP MYSQL HTML JS

SAVE & LOAD TINYMCE CONTENT WITH PHP MYSQL

SIMPLE CONTENTS TABLE id | int(11) PRIMARY text | text

CONTENT DATABASE

01

HTML FORM <form method="post">   <input type="hidden" name="id"   value="123"/>   <textarea id="mce" name="content">   </textarea>  </form>

SAVE CONTENT PART A - HTML

02

SAVE FORM ON SUBMIT <?php if (isset($_POST["content"])) { require "save.php" }

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

$stmt->execute([   $_POST["id"], $_POST["content"] ]);

SAVE INTO DATABASE $stmt = $pdo->prepare("REPLACE INTO `contents` (`id`, `text`) VALUES (?,?)"); 

SAVE CONTENT PART C - PHP

03

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

LOAD CONTENT FROM DATABASE

04

$content = $stmt->fetch(); echo $content["text"];

RETRIEVE FROM DATABASE $stmt = $pdo->prepare("SELECT * FROM `contents` WHERE `id`=?");  $stmt->execute([ID]);