Jump to content

help displaying


Nairb

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/472-help-displaying/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.