");
while($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
$sql="SELECT * FROM story_chunks WHERE in_story_id='{$row['story_id']}' AND position = 1";
$result2=mysql_query($sql, $conn) or die(mysql_error());
$row2=mysql_fetch_array($result2, MYSQL_ASSOC);
echo('
');
$sql="SELECT * FROM story_chunks WHERE in_story_id='{$row['story_id']}' AND position = 2";
$result2=mysql_query($sql, $conn) or die(mysql_error());
if(($row2=mysql_fetch_array($result2, MYSQL_ASSOC))&&($text=$row2['data'])) {
$words=explode(' ',$text);
$text='';
$x=0;
while($x<18 && $words[$x]) {
$text.=' '.$words[$x++];
}
echo("
$text ...
");
}else {
$sql="SELECT * FROM story_chunks WHERE in_story_id='{$row['story_id']}' AND type = 'text' ORDER BY position";
$result2=mysql_query($sql, $conn) or die(mysql_error());
if(($row2=mysql_fetch_array($result2, MYSQL_ASSOC))&&($text=$row2['data'])) {
$words=explode(' ',strip_tags($text));
$text='';
$x=0;
while($x<18 && $words[$x]) {
$text.=' '.$words[$x++];
}
echo("
$text ...
");
}
}
}
echo("