capella07 Posted January 13, 2010 Share Posted January 13, 2010 I have a query in a PHP/MySQL Web application that is returning (among other things), into a dynamically-built HTML table, the boolean column "IsOnTime" as a 1 or 0. The HTML table is being built like this: echo '<table>' while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr> <td align="left">' . $row['IsOnTime'] . '</td> </tr>'; } // Close the table echo '</table>'; I would like to display the boolean fields as a "Yes" or "No". How can I do that? (I actually have four boolean fields I'll need to do that to...) Thanks for anyone's help! Link to comment https://forums.phpfreaks.com/topic/188321-how-do-i-change-boolean-output-from-query-to-text-value-in-table/ Share on other sites More sharing options...
salathe Posted January 13, 2010 Share Posted January 13, 2010 You could use the ternary operator like ... ($row['isOnTime'] ? 'Yes' : 'No') ... Link to comment https://forums.phpfreaks.com/topic/188321-how-do-i-change-boolean-output-from-query-to-text-value-in-table/#findComment-994169 Share on other sites More sharing options...
capella07 Posted January 13, 2010 Author Share Posted January 13, 2010 That did the trick! Thanks a lot, salathe. Link to comment https://forums.phpfreaks.com/topic/188321-how-do-i-change-boolean-output-from-query-to-text-value-in-table/#findComment-994230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.