How to show a litle contents of articles?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • herrykng
    New Member
    • Mar 2010
    • 1

    How to show a litle contents of articles?

    I have the script:

    Code:
    <h1>List Articles</h1>
    <?php
    // Conection to mysql
    require_once ('../connection/class.mysql.php');
    $data = new Mysql();
    $data->connect();
    // query SQL to read all the articles sorted according to its id
    $query = "SELECT * FROM newsdb ORDER BY newsid";
    $result = mysql_query($query);
    while ($data = mysql_fetch_array($result))
    {
       // display titles of articles and little content of the articlel
       echo "<h3><a href='view.php?newsid=".$data['newsid']."'>".$data['title']."</a></h3>";
       if(!empty($data['pictures'])){
       echo "<P><img align=left width=200px vspace=6 hspace=12 src='../images/".$data['pictures']."'></a>";} echo "<p align=justify>".$data['content']."</p>";
    }
    ?>
    From the script I have above, I want to show a litle content of the article. How? How script to I must add into the script above?
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    quick and dirty way to do it: sub_str()

    Also take a look at str_word_count( ).

    The manual is a very good source if information. Memorize it if you have to.



    Dan

    Comment

    Working...