What are the different ways to separate an echo of single long text value MySQL table?
As I already found here, I can query the table by rows and limit them, like that:
<?php
// Perform query.
$sql = "SELECT * FROM table limit 4";
$result = $conn->query($sql);
// Fetch results
while (true) {
$row = $result->fetch_assoc();
if (!$row) {
break;
}
$rows[] = $row;
}
But it is not fetching me as a solution because I have a single table variable as text, and it is big ( ~100 words). So I cannot delimit it or query by raws since it is a single table variable.
I am looking for a solution since I got this JavaScript onclick function read more/read less (button at bottom of the article)
<script>
function readPost() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("more");
var btnText = document.getElementById("myBtn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
</script>
Here i added per request the simple blog html/php part ,hope it helps.
<?php
$query_articles = mysqli_query($link, "SELECT title,pubdate,text FROM `articles`");
$fetch_post = mysqli_fetch_assoc($query_articles);
?>
<div class="card mb-4">
<div class="card-body">
<h2 class="card-title">
<?php
echo $fetch_post['title'];
?>
</h2>
<p class="card-text">
<?php
echo $fetch_post['text'];
?>
</p>
<a href="#" class="btn btn-primary" id="read_button" onclick="readMore()">Read More</a>
</div>
<div class="card-footer text-muted">
<?php
echo $fetch_post['pubdate'];
?>
</div>
</div>