Nairb Posted May 16, 2003 Share Posted May 16, 2003 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 <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 Quote Link to comment https://forums.phpfreaks.com/topic/472-help-displaying/ Share on other sites More sharing options...
Nairb Posted May 17, 2003 Author Share Posted May 17, 2003 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"; } Quote Link to comment https://forums.phpfreaks.com/topic/472-help-displaying/#findComment-1606 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.