Jump to content

[SOLVED] Syntax error problem


cenarius

Recommended Posts

I want to make every second table row with one color background, so you get:

coloe1

color2

color1

color2

...

 

In the WHILE, I increase $tablerow for 1 and then check the % of it. See the code.

 

 

Reported error is: Parse error: syntax error, unexpected '{' in /home/a2981217/public_html/ladder.php on line 39

 

Script:

<html>
<body text="white" bgcolor="black">
<?php
$tablerow = 0;
$con = mysql_connect(xxxxxxxxxxxxxxxxxxxxxxxxxxxxx);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("xxxxxxxxxxxx", $con);

$result = mysql_query("SELECT * FROM Players");

echo '<table border="2" bgcolor="black" align="center" bordercolorlight="grey" bordercolordark="black" cellpadding="5">
<tr>
<th>Player</th>
<th>Points</th>
<th>Last question answered correctly</th>
<th>Last entry by</th>
<th>Date and time of last point entry</th>
</tr>';

while($row = mysql_fetch_array($result))
{
  $tablerow++;
  $checkrow = $tablerow % 2;
  if ($checkrow == 1)
  {
  echo "<tr bgcolor='993333'>";
  echo "<td>" . $row['Player'] . "</td>";
  echo "<td>" . $row['Points'] . "</td>";
  echo "<td>" . $row['Question'] . "</td>";
  echo "<td>" . $row['Moderator'] . "</td>";
  echo "<td>" . $row['Date'] . "</td>";
  echo "</tr>";
  }
   else ($checkrow == 0)
   {
   echo "<tr bgcolor='CCCCCC'>";
   echo "<td>" . $row['Player'] . "</td>";
   echo "<td>" . $row['Points'] . "</td>";
   echo "<td>" . $row['Question'] . "</td>";
   echo "<td>" . $row['Moderator'] . "</td>";
   echo "<td>" . $row['Date'] . "</td>";
   echo "</tr>";
   }
}
echo '</table>';

mysql_close($con);
?> 

</body>
</html>

 

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/167974-solved-syntax-error-problem/
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.