I'm trying to display a certain amount of words on one page from a database entry. For ex., on my main page I want to display the first 50 words of a story then a link will lead you to the rest of the story. I kind of know what I need to do but I don't know where to put the code. I want to display the first 50 words from 'story'. Here is my code.

<table width="760" border="3" bordercolor="ffffff" cellspacing="1" cellpadding="0">

@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM news ORDER BY ID DESC LIMIT 0, 1";




while ($i < $num) {
$story=mysql_result ($result,$i,"story");

<td bgcolor="ffffff" width="400" valign="top"><img src="mainpic.jpg"></img></td>
<td bgcolor="ffffff" width="360" valign="top"><h4><? echo "$headline"; ?></h4><h3><? echo "$story"; ?></h3><a href="view_story.php?id=<? echo "$id"; ?>" style="text-decoration:none"><h5>read more...</h5></a></td>

echo "</table>";


I'm not sure if you can do this purely with MySql.

My initial gut feeling would be to store the text in an array and then use php to count the words. Words are delimited by whitespace.