Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.