Jump to content

[SOLVED] Adding a decimal to an output echo


suttercain

Recommended Posts

Good morning everyone,

 

I have a question. I know it's pretty basic but I was unable to find the answer on my own on php.net so maybe someone can help me out.

 

I am echoing a varchar column from a MySQL database. In this column I have some integers and some doubles. Exp: 1.5, 2, 3.0, 5.

 

WHAT I NEED:

The numbers that already have a decimal are echoed in the correct format. I need the numbers with no decimal (2, 5, etc.) to be echoed with one decimal to match the others in the column. Exp: I need 2 to be echoed as 2.0, 5 as 5.0, etc.

 

Here is the code that is being echoed:

  echo "<tr class=\"$class\">\n";
  echo "<td>$row[sub_class]</td>\n";
  echo "<td>$row[disp] L</td>\n";
  echo "<td>$row[fuel]</td>\n";   <--------------- THIS IS WHERE I NEED THE DECIMAL POINT
  echo "</tr>\n";

 

Anyone have any suggestions?

 

Thank you in advance.

Link to comment
Share on other sites

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.