tpl41803 Posted November 4, 2009 Share Posted November 4, 2009 Obviously I've worded my title poorly. I am trying to write a script that will change outputted data conditionally. For example, I have a website that displays the inventory of a used car lot. Frequently, especially with older vehicles, we do not have mileage information. So, as far as the database is concerned the mileage = 0. However, when I output that data on the page I don't want the Mileage to be displayed as 0, I want to display something like "Call for Mileage." I currently have all the mileage information saved in a Int(20) field in my database, otherwise I would just have that data saved directly into the database. Is this even possible? I've tried a few different things, but it doesn't seem to be working. Can anyone point me in the right direction? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/180309-change-outputted-data-in-display-only/ Share on other sites More sharing options...
tpl41803 Posted November 4, 2009 Author Share Posted November 4, 2009 I am trying this: if ($row['mileage'] == 0) { $mileage = 'Call for Mileage'; } else { $mileage = number_format($row['mileage']); } But it doesn't seem to work properly. It changes everything to "Call for Mileage" rather than just the ones that equal 0 Quote Link to comment https://forums.phpfreaks.com/topic/180309-change-outputted-data-in-display-only/#findComment-951153 Share on other sites More sharing options...
Mchl Posted November 4, 2009 Share Posted November 4, 2009 The code looks correct. It could be giving you this result, because the field returned from query is not actually called 'mileage'. What does var_dump($row) show? Quote Link to comment https://forums.phpfreaks.com/topic/180309-change-outputted-data-in-display-only/#findComment-951304 Share on other sites More sharing options...
fenway Posted November 14, 2009 Share Posted November 14, 2009 This is clearly outside the scope of "mysql". Quote Link to comment https://forums.phpfreaks.com/topic/180309-change-outputted-data-in-display-only/#findComment-957456 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.