/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$mysql = new mysqli('localhost', 'root', 'root', 'databaseName') or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT id, title, content FROM tableName'); $stmt->execute(); $stmt->bind_result($id, $title, $content); while($row = $stmt->fetch()) : ?> <h2> <?php echo $title; ?> </h2> <p> <?php echo $content; ?> </p> <?php endwhile; ?>
Comments
