2006-03-10, 03:35 PM
Im making a little script to output the last 4 recent posts.
outputs
Why is it not incrementing the row numbers?
<html>
<head>
<style type="text/css">
div.row1{background-color: blue;}
div.row2{background-color: pink;}
</style>
</head>
<?php
$forumpath = "./forum/"; // Path to your forums root directory (with trailing slash)
require $forumpath."inc/config.php";
mysql_select_db($config['database'], mysql_connect($config['hostname'], $config['username'], $config['password']));
$query = mysql_query(
"SELECT `mybb_threads`.`tid`, `mybb_threads`.`subject`
FROM mybb_threads
WHERE (`mybb_threads`.`visible` =1)
ORDER BY `mybb_threads`.`tid` DESC
LIMIT 4"
)
or die(mysql_error());
echo "cheese";
$recentpostsinc = 1 ;
while($recentposts = mysql_fetch_assoc($query))
{
if ($recentpostsinc = 3 )
{
$recentpostsinc = 1 ;
}
echo "<div class=\"row".$recentpostsinc."\"><a href=\"./forum/showthread.php?tid=".$recentposts['tid']."\" target=\"_blank\">".$recentposts['subject']."</a></div>";
$recentpostsinc++ ;
}
?>
</html>
outputs
<html>
<head>
<style type="text/css">
div.row1{background-color: blue;}
div.row2{background-color: pink;}
</style>
</head>
cheese<div class="row1"><a href="./forum/showthread.php?tid=187" target="_blank">All my Habbo alts</a></div><div class="row1"><a href="./forum/showthread.php?tid=186" target="_blank">My paint art</a></div><div class="row1"><a href="./forum/showthread.php?tid=183" target="_blank">Rip a record</a></div><div class="row1"><a href="./forum/showthread.php?tid=182" target="_blank">Template FAQ</a></div>
</html>
Why is it not incrementing the row numbers?