Hi,

i have the following snippet of php that i wrote but cant figure out why it wont work all the variables have been set before hand.

Heres the PHP:

echo "<table border='1'>
<tr>";
if ($win_score > $lose_score) {
echo "
<th>Winner</th>
<th>Loser</th>
<th>Win Score</th>
<th>Lose Score</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['winner'] . "</td>";
  echo "<td>" . $row['loser'] . "</td>";
  echo "<td>" . $row['win_points'] . "</td>";
  echo "<td>" . $row['lose_points'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
}

When $win_score value is greater than $lose_score value its meant to display a table with some data in it but it just displays an empty table with the column headers.

You forgot to close the if bracket at the end.

Oops i forgot to include that in my post but it is definetly there inmy php code so its not that.

show the sql to populate the result array, just hunting for ideas

Hi,

i have the following snippet of php that i wrote but cant figure out why it wont work all the variables have been set before hand.

Heres the PHP:

echo "<table border='1'>
<tr>";
if ($win_score > $lose_score) {
echo "
<th>Winner</th>
<th>Loser</th>
<th>Win Score</th>
<th>Lose Score</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['winner'] . "</td>";
  echo "<td>" . $row['loser'] . "</td>";
  echo "<td>" . $row['win_points'] . "</td>";
  echo "<td>" . $row['lose_points'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
}

When $win_score value is greater than $lose_score value its meant to display a table with some data in it but it just displays an empty table with the column headers.

The table opening tag is outside of the if loop take the table closing tag too outside of it.
and it might be possible the if condition must be failing as you saying there is no table at all, you can check with it too.