Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
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');
<?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
}