dongtu7205 2012-05-30 01:21
浏览 35
已采纳

我的网站“阅读更多”功能的问题

I need your help with doing a Read More feature for my website. Contents that the Read More feature will be applied on are generated dynamically. When I implement it, and I click the Read More...i'm taken to the same page and the full article dosent show.

Please how can I fix this.

Thank you.

<?php

$row['article_content'];

if (strlen($row['article_content']) > 500) {
  $shortText = substr($row['article_content'], 0, 100);
    $shortText .= '... <a href="site/article.php?id=' . $id . '">Read More</a>
 echo $shortText;

} ?>

  • 写回答

1条回答 默认 最新

  • doulang6013 2012-05-30 02:01
    关注
    <?php
    
    if(isset($_GET['readmore']))
    echo $row['article_content'];
    else
    echo get_short_text($row['article_content']); 
    
    
    function get_short_text($article)
     {
       $shortText="";
       if (strlen($article) > 500) {
           $shortText = substr($article, 0, 100);
           $shortText .= '... <a href="site/article.php?id=' . $id . '&readmore=1'>Read More</a>
       }
       else { $shortText = $article; }
    
       return $shortText;
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计