Log in

View Full Version : Huhmmmm...



Hitman
10-12-2007, 08:18 PM
Hm, I have a layout that's interesting. It has two coloured boxes, green and grey. I want to display my news in them, but in a certain way. The latest news will be at the top, the oldest at the bottom. So lets say there are 5 news peices. Number 5 is the newest so it'd be at the top, in a grey (or green) box. Then the box below is grey, then green, then grey, then green etc... How would I do that...?

PHP code to display.


<?
if ($_SESSION['logged_user'] == true) {

$query = mysql_query("SELECT `level` FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");
$rows = mysql_fetch_array( $query );
if ($_SESSION['logged_user'] == true) {

$query = mysql_query("SELECT `level` FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");
$rows = mysql_fetch_array( $query );
if ($rows['level'] == 5) {
$query = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 0,1 ");
while($rows = mysql_fetch_array($query)) {
echo "<strong>".$rows['title']."</strong><p></p>".$rows['content']."<p></p>By ".$rows['by']." on ".$rows['date']."<p></p><a href=\"./delete.php?id=".$rows['id']."\">Delete Entry</a></br></br></br>";
}
} else {
$query = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 0,1 ");
while($rows = mysql_fetch_array($query)) {
echo "<strong>".$rows['title']."</strong><p></p>".$rows['content']."<p></p>By ".$rows['by']." on ".$rows['date']."";
}
}
}
}
if ($_SESSION['logged_user'] == false) {
echo "Not logged in!";
}
?>

Also how would I be able to do something when there are over 10 news results it makes a new page with the link?

Want to hide these adverts? Register an account for free!