Hello!
I am new here and rather inexperienced when it comes to coding, php and mysql. So please be patient :queasy:
I'd like to display the three lates news from a database in a newscolumn on the indexpage of a website. This worked fine by simply limiting the output.
However, I would not only like to limit the number of outputs but also the length of the text displayed. I like to display only about 250 characters of each of the newstexts. If the reader wants to read the whole story, he/she will have to click on a link that will lead to the news-archives.
Could anyone help me with some advice how to do this.
Thank you very much. I attach a copy of the script below.
Best wishes from Sweden /Felix
<?
$query="SELECT * FROM news ORDER BY id DESC LIMIT 0, 3";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<?
echo "<div class=indexnews></b>";
?>
<table>
<tr bgcolor="#ffffff">
<td colspan="5"></td>
</tr>
<tr bgcolor="#A2B3BF">
<td colspan="5"></td>
</tr>
<tr bgcolor="#A2B3BF">
<td colspan="5"><div align="center"><font size="3"><strong>Latest News</strong></font></div></td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="5"></td>
</tr>
<tr>
<td width="8"><div align="center"></div></td>
<td width="39"><div align="center"></div></td>
<td width="233"><div align="center"></div></td>
<td width="10"><div align="center"></div></td>
</tr>
<?
$i=0;
while ($i < $num) {
$datum=mysql_result($result,$i,"datum");
$title=mysql_result($result,$i,"title");
$newstext=mysql_result($result,$i,"newstext");
$source=mysql_result($result,$i,"source");
?>
<tr>
<td align="left" > </td>
<td colspan="2" align="left" ><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><? echo $datum; ?></strong></font></div></td>
<td align="left" > </td>
</tr>
<tr>
<td align="left" > </td>
<td colspan="2" align="left" ><div align="center"><font face="Arial, Helvetica, sans-serif"><strong><? echo $title; ?></strong></font></div></td>
<td align="left" > </td>
</tr>
<tr>
<td align="left" > </td>
<td colspan="2" align="left" ><div align="justify"><font face="Arial, Helvetica, sans-serif"><? echo $newstext; ?></font></div></td>
<td align="left" > </td>
</tr>
<tr>
<td align="left" > </td>
<td colspan="2" align="left" ><div align="right"><font face="Arial, Helvetica, sans-serif"><a href="http://www...latestnews.php">Read more here...</a> </font></div></td>
<td align="left" > </td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="5"></td>
</tr>
<?
$i++;
}
echo "</table>";
?>
</div>