Author Topic: help displaying  (Read 1101 times)

0 Members and 1 Guest are viewing this topic.

Offline NairbTopic starter

  • Enthusiast
  • Posts: 68
    • View Profile
help displaying
« on: May 16, 2003, 04:39:42 PM »
umm, ok I\'m trying to display my news results, but it\'s showing 5 of each
here\'s the code:

Code: [Select]
<?

include("./admin/config.php");

$conn=mysql_connect ("$servername", "$dbusername", "$dbpassword") or die (\'I cannot connect to the database because: \' . mysql_error());

mysql_select_db ("$dbname");



$sql = "SELECT * FROM news ORDER BY newsid ASC LIMIT 0,30";

$getnews = mysql_query($sql);

$numofrows = mysql_num_rows($getnews);



while($row = mysql_fetch_array($getnews))

{

echo "<table width=90%>";

for($i = 0; $i < $numofrows; $i++) {

    if($i % 2) {

        $color = "#BBBBBB";

    } else {

        $color = "#EEEEEE";

    }

$username = $row["newsauthor"];

$avatar = $row["useravatar"];

$email = $row["useremail"];

$subject = $row["newsubject"];

$newstext = $row["newstext"];



echo "<tr><td><br><table width=90% cellspacing=0 cellpadding=1 bgcolor=000000><tr><td>

<TABLE bgcolor=$color width=100%><tr>

<td>Username: <b>$username &nbsp; <img src="$avatar"></b></td> </tr>

<tr> <td>Email: <b>$email</b></td> </tr>

<tr> <td>Subject: <b>$subject</b></td> </tr>

<tr> <td>News: <b>$newstext</b></td> </tr> </table></td> </tr> </table></td></tr>";

}

echo "</table>";

}







?>


Any help is welcome, thanks                    

Offline NairbTopic starter

  • Enthusiast
  • Posts: 68
    • View Profile
help displaying
« Reply #1 on: May 17, 2003, 10:47:21 AM »
Ohh ya, I forgot to mention

I\'m trying to make it have alternating colors...

that\'s what this part is for:

Code: [Select]
for($i = 0; $i < $numofrows; $i++) {

    if($i % 2) {

        $color = "#BBBBBB";

    } else {

        $color = "#EEEEEE";

    }