Replacing PHP data output with fixed values

3479 views php
5

echo "<td>" . $row['Rp'] . "</td>"; 
echo "<td>" . $row['Sp'] . "</td>";

In the above PHP snippet, I'd like to change the data output with fixed values like "1" for Rp, "2" for Sp. Sometimes there are no data output, in these cases, it should be blank. How can I do this with php? (if there is an easy way). Thanks.

Note: I don't want to use a function in query for this.

answered question

1 Answer

11

echo '<td>' . empty($row['Rp']) ? '' : 1 . '</td>'; 
echo '<td>' . empty($row['Sp']) ? '' : 2 . '</td>';

posted this

Have an answer?

JD

Please login first before posting an answer.