Hello ppl
I found a script that reads from a db some news in format Title - date and content ... this is the script:
<?
require ("database.inc.php"); //here are the username and pass
$result = mysql_query ("SELECT subject,content,timestamp FROM news ORDER BY timestamp DESC");
while ($data = mysql_fetch_array ($result))
{
?>
<tr><td><b><? echo $data["subject"]; ?></b>[<? echo date("d. m. Y", $data["timestamp"]) ?>]</td></tr>
<tr><td><? echo nl2br($data["content"]) ?></td></tr>
what I want is to include the second script witch will cut the content to 30 char's and add a link after for full story. But I don't know how to combine those scripts or how to store the content in $string .
This is the 2nd script.
<?
function cutMore($string,$more_link,$max_length=30,$format='... [{link}]',$title='more')
{
$string=trim($string);
if(strlen($string)>$max_length)
{
$string=substr($string,0,30);
$last_pos=strrpos($string,' ');
if($last_pos!=false)
$string=substr($string,0,$last_pos);
$format=str_replace('{link}','<a href="'.$more_link.'">'.$title.'</a>',$format);
$string.=$format;
}
else
{
/* it's not longer. Well, you can now either add the [more] link anyway or just do nothing
* just uncomment the 2 lines by removing the "#" below if you want the [more] link added */
#$format=str_replace('{link}','<a href="'.$more_link.'">'.$title.'</a>',$format);
#$string.=$format;
}
return $string;
}
?>
Can somebody help me?