Can anyone help me format it to a variable that I can loop? Sounds simple to me, but I can't figure it out, but I've only been at PHP for a few weeks, so I'm still trying to figure it all out.
Thanks in advance for any help you can give me!
S
Code: Select all
<?php
$username="blood_admin";
$password="*********";
$database="blood_bands";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select databse");
$query="SELECT * FROM stories";
$result=mysql_query($query);
$num=mysql_num_rows($result);
?>
<?
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"name");
$title=mysql_result($result,$i,"title");
$story=mysql_result($result,$i,"story");
?>
<?
$str = "$story";
$no_of_words = 20;
$str_array = split(" ",$str,$no_of_words+1);
if(count($str_array)>$no_of_words) {
for($i=0; $i < $no_of_words; $i++) {
echo $str_array[$i]." "; }
echo "<b>...........(more)</b>";}
?>
<?
$i++;
}
?>