I’ve got just a quick problem. I’ve got code that returns the last post for separate titles for a forum. I want to limit the number of characters shown and put the (… …).
I’m having difficulty with a nested if statement in my while loop:
$query = "SELECT comment FROM Assembly WHERE title = 'Checkered' ORDER BY date DESC LIMIT 1";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($message))
{
if(strlen($message) > 10)
{
echo substr($message, 0, 10)."…";
}
else
{
echo "Last Post:<br>";
echo strip_tags("{$row['comment']}");
}
}
thanks in advance 🙂
**edit
yes css text-overflow:ellipsis; works great!! Thanks guys
***edit working code incase you want
$query = "SELECT comment FROM Assembly WHERE title = 'Checkered' ORDER BY date DESC LIMIT 1";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
$comment = strip_tags($row['comment']);
if(strlen($comment) > 30)
{
echo substr($comment, 0, 30)."...";
}
else
{
echo "Last Post:<br>";
echo $comment;
}
}
You give nout over as to the problem but I am going to go out on a limb and guess the problem. Try this: