Q1. I am developing a News page for my site and on the Home Page i want to just include a short snippet (approx 177 characters including spaces) on the content, then anything after that would be left out and there would be a "more..." link to the actual news item page.
Q2. The date would be auto generated using the NOW() function, but that come up with YYYY-MM-DD, how can i modify it so it comes up with DD-MMM-YYYY(if possible)
Q3. On the Home Page I only want the five latest news items to be on there. How can I do a query that will only show the five latest posts?
My coding for the Home Page is below:
For those interested, this is the addy to the home page: ( )
Make Sense? I hope so (-:
Q2. The date would be auto generated using the NOW() function, but that come up with YYYY-MM-DD, how can i modify it so it comes up with DD-MMM-YYYY(if possible)
Q3. On the Home Page I only want the five latest news items to be on there. How can I do a query that will only show the five latest posts?
My coding for the Home Page is below:
Code:
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM news ORDER BY id ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "";
?>
<!-- BORING HTML GOES HERE --!>
<? $i=0;
while ($i < $num) {
$date=mysql_result($result,$i,"date");
$author=mysql_result($result,$i,"author");
$headline=mysql_result($result,$i,"headline");
$content=mysql_result($result,$i,"content");
$id=mysql_result($result,$i,"id");
?>
<table border="0" width="100%" cellpadding="0">
<tr>
<td width="80%" colspan="2" align="center">
<a href="news.php?=<? echo "$id"; ?>"><? echo "$headline"; ?></a>
</td>
</tr>
<tr>
<td width="100" height="75" valign="middle">
<p align="center"><a href="contact?=<? echo "$author"; ?>"><img src="images/<? echo "$author"; ?>.jpg" width="60" height="60" alt="Email <? echo "$author"; ?>"
border="0" style="border: 1px solid rgb(0,0,0)"></a>
</td>
<td width="81%" valign="middle">
<p align="left"><b><? echo "$date"; ?></b><br><? echo "$content"; ?> <a href="news.php?=<? echo "$id"; ?>" class="news">more...</a>
</td>
</tr>
<tr>
<td height="20">
</td>
</tr>
<?
++$i;
}
echo "</table>";
?>
<!-- THE REST OF THE HTML GOES HNOIRE --!>
For those interested, this is the addy to the home page: ( )
Make Sense? I hope so (-: