vendredi 6 novembre 2015

IF and ELSE in ECHO TABLE

I try to make a little formula in a <td> ... </td> of a table which generate dates from my database :

while ($row = $result->fetch_assoc()) {
    echo "<tr>";
 echo "<td>" . $row['Pos']. "</td>"; 
 echo "<td><b>" . $row['Prev'] . "</b></td>";
 echo if ($row["Prev"]>$row["Pos"]) {"<td>".($row["Prev"]-$row["Pos"])."</td>";}
 else {"<td>".($row["Prev"]-$row["Pos"])."</td>";};
 echo "<td>" . $row['Logo'] . "</td>";
 echo "<td><b>" . $row['Team'] . "</b><br /><i>" . $row['Flag'] . $row['Country'] . "</i></td>";
 echo "<td><b>" . $row['TOTALPts'] . "</b></td>";
 echo "<td>" . $row['Pts15'] . "</td>";
 echo "</tr>";
}
echo "</table>";

here is the problem :

echo "<td>".($row["Prev"]-$row["Pos"])."</td>";

I want to create an IF, but can't because is in ECHO and I receive a error :

 If ($Prev>$Pos) { img ++ }
 else { img -- } 

this code must be in a <td> </td> in php code

I will have 3 images .... enter image description here

Aucun commentaire:

Enregistrer un commentaire