Jump to content


Photo

help displaying


  • Please log in to reply
1 reply to this topic

#1 Nairb

Nairb
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationCanada

Posted 16 May 2003 - 08:39 PM

umm, ok I\'m trying to display my news results, but it\'s showing 5 of each
here\'s the code:

<?

	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

#2 Nairb

Nairb
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationCanada

Posted 17 May 2003 - 02:47 PM

Ohh ya, I forgot to mention

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

that\'s what this part is for:

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

    if($i % 2) { 

        $color = "#BBBBBB"; 

    } else { 

        $color = "#EEEEEE"; 

    } 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users