I am trying to get information out of a data base and print it onto a page and have the information print into a table and have the table rows alternate between two colors. The script that I am trying to fix is this:
It's results print this: http://www.mlowery.net/AC/roster2.php
The original script that I used which doesn't print the info into a table is this:
It's results print this: http://www.mlowery/net/AC/roster.php
Can someone please help.
PHP:
<?
$host = "localhost";
$user = "user";
$pass = "pass";
$db = "db";
mysql_connect($host, $user, $pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db);
$result = mysql_query("SELECT * FROM roster ORDER BY roster.screen_name ASC");
echo "<TABLE>";
while($row = mysql_fetch_array($result) ) {
if (!isset($bgcolor) || $bgcolor == "#5B4613") $bgcolor = "#D2B77E";
else $bgcolor = "#5B4613";
echo "<tr><td bgcolor=\"".$bgcolor."\">$screen_name['screen_name']</td></tr>";
}
echo "</TABLE>"
?>
The original script that I used which doesn't print the info into a table is this:
PHP:
<font ="textsize">
<?
$host = "localhost";
$user = "user";
$pass = "pass";
$db = "db";
mysql_connect($host, $user, $pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db);
$result = mysql_query("SELECT * FROM roster ORDER BY roster.screen_name ASC");
while($screen_name = mysql_fetch_array($result) )
{
echo $screen_name['screen_name'] . "<br>";
}
?>
Can someone please help.