Originally posted by Weedpacket
The most resonable approach would be to have a variable which counts each row as it's displayed, and then look at the value of that variable to decide whether five rows have already been displayed or not.
Okay this is my code but it just goes to the second option only!!
any ideas how to fix this?
<?php
mysql_connect (localhost, user, pass);
mysql_select_db (table);
$result = mysql_query ("SELECT * From news WHERE MAIN = 0 order by id desc limit 15");
$i = 1;
while ($row = mysql_fetch_array($result)) {
$i++;
?>
<?php
If ($i >= "5") {
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<table border="0" style="border-collapse: collapse" id="table1" width="450">
<tr>
<td align="left" valign="top"><span style="text-transform: uppercase">
<b><font size="1" face="Verdana">
<a href="http://www.rugbyleaguenz.com/news.php?id=<?php echo $row["id"];?>">
<font color="#000000"> <?php echo $row["header"];?> <br></font></a></font></b></span>
<font color="#999999" size="1" face="Verdana"><i>
<?php echo $row["datestring"];?></i>
</font><br></font></a></font></b></span>
</font></a></font></b></span><font size="1" face="Verdana">
<?php
$txt = $row['body'];
$txt = explode(" ", $txt);
$txt = array_slice($txt, 0, 50);
$txt = implode(" ", $txt);
$s = "$txt...\n";
echo $s;
?> [<a href="http://www.rugbyleaguenz.com/news.php?id=<?php echo $row["id"];?>"><font color="#000000">more</font></a>]
</font></td>
<td align="center" valign="top">
<p align="center">
<img border="1" src="<?php echo $row["IMG"];?>" align="right" width="145" height="145"></p>
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2"> </td>
</tr>
<tr>
<td align="left" valign="top" colspan="2" bgcolor="#CCCCCC" height="1">
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2"> </td>
</tr>
</table>
<?php
} else {
?>
<?php echo $row["header"];?>
<?php
}
}
?>
</body>
</html>