Code:
<div id="apDiv1">
<div id="apDiv2">
<h2>Welcome to the Stories Archive</h2>
<br />
<p>You will find here and extensive collection of stories. Even better than that, this story archive is easy to use.</p>
<p>The Stories are listed in order of newest to oldest so the latest story will always be right at the top of the list for you to read.</p>
<p>As an added bonus, you can view and add comments about the stories, this is great if you find a problem with a story, or just want to make general comments.</p>
<p>You too can add stories to the story archive to share with everyone.</p>
<p>Enjoy searching through the stories ^_^</p>
<p> </p>
<a href="stories_upload.php">Add a new story</a>
</div>
<?php
$host = "host";
$username = "name";
$password = "pass";
$database = "dbname";
$server = mysql_connect($host, $username, $password);
$connection = mysql_select_db($database, $server);
$server = mysql_connect($host, $username, $password);
$db = mysql_select_db($database, $server);
$numofrows = @mysql_num_rows($result);
$sql = mysql_query('SELECT * FROM `storys` ORDER BY `id` DESC');
print '<table width="650" border="0" cellpadding="2" cellspacing="1">\n';
print '<tr><th>Story</th><th>Author</th></tr>\n';
while($row = mysql_fetch_array($sql, MYSQL_BOTH)) {
for($i = 0; $i < $numofrows; $i++)
{
$row = @mysql_fetch_array($result);
if($i % 2)
{
print '<TR bgcolor="#333333">\n';
}
else
{
print '<TR bgcolor="#444444">\n';
}
printf("<td><a href=\"story_display.php?id=%s&usrname=$usrname\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td>\n", $row["id"], $row["title"], $row["author"], $row["id"]);
print "</TR>\n";
}
print "</table>\n";
?>
<br/ >
</div>
hi im trying to get my table to print in alternating colours so i followed a tutorial but it dosnt work it just errors out saying there is a unexpected $end. Pls help.
http://www.scriptplayground.com/tutorials/php/Alternating-Row-Color/ tutorial url