cenarius Posted July 29, 2009 Share Posted July 29, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/167974-solved-syntax-error-problem/ Share on other sites More sharing options...
Maq Posted July 29, 2009 Share Posted July 29, 2009 Line:38 should be 'elseif'. 'else' does not take a condition. Quote Link to comment https://forums.phpfreaks.com/topic/167974-solved-syntax-error-problem/#findComment-885980 Share on other sites More sharing options...
fooDigi Posted July 29, 2009 Share Posted July 29, 2009 line 38 uses an else with conditions, should be elseif, or just else with no conditions Quote Link to comment https://forums.phpfreaks.com/topic/167974-solved-syntax-error-problem/#findComment-885981 Share on other sites More sharing options...
cenarius Posted July 29, 2009 Author Share Posted July 29, 2009 LOL, thanks. I'm an idiot... Quote Link to comment https://forums.phpfreaks.com/topic/167974-solved-syntax-error-problem/#findComment-886167 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.