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
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

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.