From a database like this
[ POSTS ]
| id | title | part1 | part2 | part3 |
|------|--------------|-------------|-------------|-------------|
| 1 | ST1 | storyp1 | storyp1 | storyp1 |
| 2 | ST2 | storyp2 | storyp2 | storyp2 |
| 3 | ST3 | storyp3 | storyp3 | storyp3 |
| 4 | ST4 | storyp4 | storyp4 | storyp4 |
__________________________________________
How can i separate a page into 3 pieces to be shown when clicking on a button?
<?php
$query = "SELECT * FROM posts WHERE id = :id";
$stmt = $conn->prepare($sqlFetch);
$stmt->execute([':id' => $id]);
$row = $stmt->fetch()
$title = $row['title'];
$part1 = $row['part1'];
$part1 = $row['part2'];
$part1 = $row['part3'];
?>
<body>
<h1 class="title">
<?php echo $title; ?>
</h1>
<button>part1</button>
<button>part2</button>
<button>part3</button>
<div class="part1">
<?php echo $part1; ?>
</div>
<div class="part2">
<?php echo $part2; ?>
</div>
<div class="part3">
<?php echo $part3; ?>
</div>
</body>
I thought about using CSS display: none;
but couldn't figure out how to trigger the buttons, Is there a possible way to use PHP to do that? I thought about Radio buttons
too But i guess it is not the optimal way.