使用php-mysql自定义数据库查询

使用php-mysql自定义数据库查询,php,mysql,Php,Mysql,我已经建立了一个名为news和articles的数据库和表 我在桌子上插了1000字的文章 我可以从数据库中查询文章,但它会在我的浏览器上显示完整的文章,现在我只想显示100字的文章,然后使用“阅读更多”按钮。 当阅读更多按钮将被点击,完整的文章将显示在另一页 Select substring(detail, 1, 100) from articles 假设“detail”是表“articles”中的一列,试试这个 $word = strip_tags($word); // strip tag

我已经建立了一个名为
news
articles
的数据库和表
我在桌子上插了1000字的文章

我可以从数据库中查询文章,但它会在我的浏览器上显示完整的文章,现在我只想显示100字的文章,然后使用“阅读更多”按钮。
当阅读更多按钮将被点击,完整的文章将显示在另一页

Select substring(detail, 1, 100) from articles
假设“detail”是表“articles”中的一列,试试这个

$word = strip_tags($word); // strip tags to avoid breaking any html

if (strlen($word) > 100) 
{    
    $wordCut = substr($word, 0, 100); // truncate string
    $word = substr($wordCut, 0, strrpos($wordCut, ' ')).'... <a href="/this/story">Read More</a>'; // make sure it ends in a word so assassinate doesn't become ass...
}
echo $word; 
$word=strip_标签($word);//剥离标记以避免破坏任何html
如果(strlen($word)>100)
{    
$wordCut=substr($word,0100);//截断字符串
$word=substr($wordCut,0,strrpos($wordCut,,)...........;//确保它以一个单词结尾,这样暗杀者就不会变成蠢货了。。。
}
回声$字;

只是对未来问题的提示:您应该尝试包含一些您有问题的代码,以便更容易提供帮助。