johnnys Posted June 14, 2013 Share Posted June 14, 2013 Hi, I have a table row that outputs some info, works fine - however instead of it displaying a '1' i'd like it to display 'yes'. Or if the field is empty display a 'n/a'. Is there anything I can add to my code below to get it working? <tr> <th>Is Processed?</th> <td>{$result['isProcessed']}</td> </tr> Thanks in advance J Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/ Share on other sites More sharing options...
louie35 Posted June 14, 2013 Share Posted June 14, 2013 $result = $result['isProcessed'] ? "yes" : "n/a"; echo "<td>".$result."</td>"; Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/#findComment-1435974 Share on other sites More sharing options...
johnnys Posted June 14, 2013 Author Share Posted June 14, 2013 thanks for the tip now it just says ".Array." in the field ? Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/#findComment-1435980 Share on other sites More sharing options...
louie35 Posted June 14, 2013 Share Posted June 14, 2013 print the array and let me see it print_r($result['isProcessed']); Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/#findComment-1435981 Share on other sites More sharing options...
johnnys Posted June 14, 2013 Author Share Posted June 14, 2013 (edited) I moved the $result = $result['isProcessed'] ? "yes" : "n/a"; code you supplied to another part of the page and now it says 'y' in every field column, apart from the isProcessed filed where it says 'yes' Edited June 14, 2013 by johnnys Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/#findComment-1435983 Share on other sites More sharing options...
louie35 Posted June 14, 2013 Share Posted June 14, 2013 That result, I suppose is coming for a database so you need to put the code in the while... loop before it gets echoed into the page Also, it depends how you store it as well, 1 = true ...... y = y so you can modify my code to: $result = $result['isProcessed'] || $result['isProcessed'] == "y" ? "yes" : "n/a"; Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/#findComment-1435984 Share on other sites More sharing options...
Solution Barand Posted June 14, 2013 Solution Share Posted June 14, 2013 Don't assign the $result['isProcessed'] back to $result. $processed = $result['isProcessed'] ? 'yes' : 'n/a'; echo "<td>$processed</td>"; Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/#findComment-1436000 Share on other sites More sharing options...
johnnys Posted June 17, 2013 Author Share Posted June 17, 2013 thank you very much Barand - that works perfectly! also thanks for your help louie35 Quote Link to comment https://forums.phpfreaks.com/topic/279153-table-row-output-help/#findComment-1436340 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.