Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear
CREATE TABLE wp_posts ( id INT AUTO_INCREMENT, post_title VARCHAR(100), post_content VARCHAR(100), PRIMARY KEY (id) ); INSERT INTO wp_posts (post_title,post_content) VALUES ('Title 1', 'Content 1'), ('Title 2', 'Content 2');

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $pid = 2; $sql = <<<SQL SELECT post_title, post_content FROM wp_posts WHERE ID=? SQL; $stmt = mysqli_prepare($mysqli, $sql); mysqli_stmt_bind_param($stmt, "i", $pid); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt, $title, $content); if (mysqli_stmt_fetch($stmt)) { ?> <h2 align="center"><?php echo $title; ?></h2><br> <div class="paracenter"> <p id="cont"><?php echo $content; ?></p> <hr color="black" width="10%"> </div> <?php }
Copy Clear