http://ca3.php.net/manual/en/function.substr.php is the function you want

bastien


From: Benjamin Adams <[EMAIL PROTECTED]>
To: PHP DB <php-db@lists.php.net>
Subject: [PHP-DB] Only a section from the database result
Date: Tue, 18 Jul 2006 13:24:51 -0400

I have articles in a MySQL database and I want creating a fast brows where people can read read the beginning of the articles and select the ones they want to read.

How do I only display the first say 50 chars of a 5000 char article?

$count = 1;
while(($row = mysql_fetch_array($News)) or ($count < 15)){
    if(isset($row['threadid'])){
echo "<b><a href='./showpost.php?t=" . $row['threadid'] . "'>" . $row['title']. "</a></b><br \>"; echo "&nbsp;&nbsp;&nbsp;" . $row['dateline'] . " -- by: " . $row ['postusername'] . "<br \>"; echo "&nbsp;&nbsp;&nbsp;Views: " . $row['views'] . " - Comments: " . $row['replycount'] . "<br \><br \>"; echo "<p>" . $row['pagetext'] . "</p>"; //This is the variable I only want the fist 50 chars
    }
    $count++;
}

Thanks

--Ben

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to