如何从数据库中断文本并具有“阅读更多”按钮? [英] How to break text from database and have "Read More" button?

查看:68
本文介绍了如何从数据库中断文本并具有“阅读更多”按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我遇到了这个问题。

我会尽量让它变得简单。

假设有一个名为submit-article.php的页面,用户在该字段中输入其文本。它进入数据库等等......

比我在index.php页面的div中显示它。如何将index.php页面上显示的文本限制为200个字符?而不是有一个阅读更多按钮 <点击时展开div显示所有文字。

我会附上显示我的意思的图片。


谢谢



Hello,

I came over this problem.
I''ll try to make it as simple as I can.
Say there is a page called submit-article.php where users enter their text in the field. It goes in database and so on...
Than I display it in div on index.php page. How can I limit text that displays on index.php page to 200 characters? And than have a "Read More button" < When clicked expands div to show all text.
I will attach image that shows what I mean.

Thank You

附加图像
Text_break_example.jpg (91.2 KB,6222 views)
Attached Images
Text_break_example.jpg (91.2 KB, 6222 views)

推荐答案

您可以将其存储在变量然后只显示前200个字符。然后,当他们点击按钮查看更多内容时,它只是用全文替换div中的内容。
You could store it in a variable and then display only the first 200 characters. Then, when they click the button to see more, it just replaces what''s in the div with the full text.


是的,我知道它的逻辑,我的问题在代码中。这是我到目前为止所得到的:

Yeh, I kind of know the logic of it, my problem is in code. Here is what I have got so far:

展开 | 选择 | Wrap | 行号


if(strlen(
if(strlen(


这篇关于如何从数据库中断文本并具有“阅读更多”按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆