我想从数据库中计算我的文本,如果它超过(例如100)字符我想显示一个按钮阅读更多所以当你克隆它时,它发送给我全文这里是我的代码:
的index.php
$sql = "SELECT * FROM posts ORDER BY `posts`.`id` DESC";
$result = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_assoc($result)) {
echo "<div id='posts'>
<h3>".$row['titulli']."</h3>
<h5>".$row['data']."</h5>
<p>".$row['teksti']."</p>
".$count = $row['teksti'];
echo "<button><a href='post.php?titulli=".$row['titulli']."&data=".$row['data']."'>Read More</a></button></div>";
}
我添加了if语句,但我认为我写错了: 当我向其添加此代码时,它会完全制动我的页面
while ($row = mysqli_fetch_assoc($result)) {
echo "<div id='posts'>
<h3>".$row['titulli']."</h3>
<h5>".$row['data']."</h5>
<p>".$row['teksti']."</p>
".$count = $row['teksti'];
if (strlen($count > 100)) {
echo "<button><a href='post.php?titulli=".$row['titulli']."&data=".$row['data']."'>Read More</a></button></div>";
}
}
答案 0 :(得分:1)