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! Quote 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') ... Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.