PHP MYSQL

HOW TO STORE RETRIEVE HTML CODE IN PHP MYSQL

CONTENTS DATABASE

01

CONTENTS TABLE id | int(11) PRIMARY KEY content | text

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

STORE HTML CODE

02

SAVE HTML INTO TABLE $stmt = $pdo->prepare("INSERT INTO `contents` (`content`) VALUES (?)"); $stmt->execute(["<p>FOO<p>"]);

RETRIEVE HTML CODE

03

GET HTML CODE FROM DATABASE $stmt = $pdo->prepare("SELECT * FROM `contents` WHERE `id`=?"); $stmt->execute([123]); $contents = $stmt->fetch();

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