Detomah Posted April 10, 2012 Share Posted April 10, 2012 Hi there, i've had a good look around the forums and on various other sites and can't get my head around a silly little php issue i'm having and was wondering if any of the php guru's on here could possibly provide me with a simple answer/solution please, i've not even been able to get results for what i'm trying to do, as I haven't known the best text to search for this little thing. I'm retrieving data from mysql and one of the cells that I parse the results for always has either a Y or an N for that field. I'm having no issues getting it to display the Y or the N correctly. However... Rather than have it display just an N or a Y, i've been trying to get PHP to make it display either a YES or a NO instead, purely for cosmetic purposes. The php code i've been working with was part of a pre built script I'm currently customising and this bit of functionality never worked in it: <td>" . ($result[7] ? "Yes" : "No") . "</td> $result[7] being the field that contains either a y or a n for every result. Unfortunately, all that my output text does is displays a Yes regardless, even if there is a n in the dbase field. Could someone please help me, so I can get this to display a YES if the field contains a y and display a NO if the field contains a n I know this is probably a bit of a nOObie question, but I am learning this stuff still as I go along... Thanks in advance and sorry for the rather non-technical way i've worded this. Quote Link to comment https://forums.phpfreaks.com/topic/260673-changing-output-for-a-result-in-php/ Share on other sites More sharing options...
trq Posted April 10, 2012 Share Posted April 10, 2012 The reason it always displays "Yes" is because both "N" and "Y" evaluate to true. You need an expression that will evaluate to true or false. "<td>" . $result[7] == 'Y' ? "Yes" : "No" . "</td>"; Quote Link to comment https://forums.phpfreaks.com/topic/260673-changing-output-for-a-result-in-php/#findComment-1336033 Share on other sites More sharing options...
Detomah Posted April 10, 2012 Author Share Posted April 10, 2012 That's worked brilliantly. Thank you very much. I take it, that works the same for any field with a similar kind of thing, so i've just learned something new there aswell. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/260673-changing-output-for-a-result-in-php/#findComment-1336044 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.