hi all
im quite new to php.
im trying to add some dynamic content to my home page
i have a lot of daily news items in a mysql db
what i want is to show the headlines of each news item as links and the first sentence.
i hope someone can help me.
thanx
ahmed
headlines as links
Moderator: General Moderators
This will help with just the first few words/sentences:
And as for the getting of data... check around. You need a SELECT query.
Code: Select all
function truncate_small ($string, $max = 50, $rep = '') {
$leave = $max - strlen ($rep)
return substr_replace($string, $rep, $leave);
}Would be better and neater to do it int he query itself!
This will display the first 10 words
Mark
Code: Select all
$sql = "SELECT *, SUBSTRING_INDEX(story, ' ', 10) AS new_story FROM news";Mark