Jump to content

Change outputted data in display only?


tpl41803

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/180309-change-outputted-data-in-display-only/
Share on other sites

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

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.