0

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.

Edited by toasty525: n/a

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by network18
0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.