I am attempting to integrate a forum news with my website and as of now the PHP script I have written works perfect, although I am not quite sure how I would set up a character limit. I want it to so that say if there is more than 300 characters, only the first 300 are displayed and then there would be ... at the end followed by [read more] which would be linked to the thread. I am using the following code:
<p align="justify"><?php
$query = @mysql_query("SELECT tid, title, posts, start_date, starter_id, starter_name, forum_id FROM xnftopics WHERE forum_id=33 ORDER BY tid DESC LIMIT 0, 4");
while ($data = @mysql_fetch_object($query)) {
?>
<b><?=$data->title?></b>
<br>Written by <b><a href="http://www.xarnet.net/index.php?act=Profile&CODE=03&MID=<?=$data->starter_id?>"><?=$data->starter_name?></a></b>
<br><?php
$p = $data->start_date;
$a = $data->starter_id;
$t = $data->tid;
$result = mysql_query("SELECT author_id, post, topic_id FROM xnfposts WHERE topic_id=$t AND author_id=$a AND post_date=$p",$db);
$myrow = mysql_fetch_array($result);
printf("%s", $myrow["post"]);
?>
<br>
<br>
<?php
}
?></p>
So basically if the following was the post:
The server is being reformatted so the forum shall be down for at least a good part of tomorrow (or rather today for me), I apologise for this inconvenience, but it should hopefully help improve the server speeds and what not. You've probably also noticed that MySQL errors have been cut down enormously, so this should only make things even better.
I would want it to be something like:
The server is being reformatted so the forum shall be down for at least a good part of tomorrow (or rather today for me), I apologise for this inconvenience, but it should hopefully help improve the server speeds and what not. You've probably also noticed that MySQL errors have been cut down enormou... [read more]
I would have no problem linking the read more to the thread, but I don't want it displayed if the characters in the post are under 300, only if it's over 300.
Any help on this issue would be much appreciated.