在mysql中更改货币小数位

时间:2022-04-26 16:31:18

I am storing some currency values in my mysql database, I currently have the field type set to decimal(10,2) which gives me prices of £2.22 . I need to change it so it is formatted like this £1.3044 . Every time I input a value of 1.3044 to saves the value 1.30 to the database, does anyone know the correct type to display something like this ? £1.3044

我在我的mysql数据库中存储了一些货币值,我目前将字段类型设置为十进制(10,2),这给我的价格为2.22英镑。我需要更改它,因此格式化为£1.3044。每当我输入1.3044的值以将值1.30保存到数据库时,有没有人知道正确的类型来显示这样的东西? £1.3044

EDIT >>>>

编辑>>>>

After following the answer below, this now works and saves the data in the correct format, the problem is now, for some reason when it re loads it into the form field it changes it to 1.30 even though in the database it is 1.3044.

按照下面的答案后,现在可以正常工作并以正确的格式保存数据,问题是现在,由于某种原因,当它重新加载到表单字段时,它将其更改为1.30,即使在数据库中它是1.3044。

    <div class="oilprices" style="width:800px; height:auto; float:left;margin-left:15px;">
      <div style="float:left; width:235px "><span class="ccms_form_element cfdiv_text" id="oilpricegasoil"><strong><span style="font-weight:bold;margin-top:4px; float:left;"><span style="font-size:15px; padding-right:10px;">Oil Prices -   </span> Gas Oil</span> £</strong>
          <input name="oilpricegasoil" style="padding:3px !important; background:#fff;" type="text" class="form-field" id="oilpricegasoil" title="oilpricegasoil" size="3" maxlength="10" label_over="0" hide_label="0" /><span style="padding-left:2px;">PPL</span>
    </span></div>
      <div style="float:left; width:130px; margin-left:5px; "><span class="ccms_form_element cfdiv_text" id="oilpricegasoil"><strong>Derv £</strong>
          <input name="oilpricederv" type="text" style="background:#fff;padding:3px !important;" class="form-field" id="oilpricederv" title="oilpricederv" size="3" maxlength="10" label_over="0" hide_label="0" /><span style="padding-left:2px;">PPL</span>
    </span></div>
      <div style="float:left; width:135px; margin-left:5px; "><span class="ccms_form_element cfdiv_text" id="oilpricegasoil"><strong>Kero £</strong>
          <input name="oilpricekero" style="background:#fff;padding:3px !important;" type="text" class="form-field" id="oilpricekero" title="oilpricekero" size="3" maxlength="10" label_over="0" hide_label="0" /><span style="padding-left:2px;">PPL</span>
    </span></div>
    <input name="cf_id" type="hidden" id="cf_id" value="">
    <div style="width:40px; float:left;padding-left:10px"> 

        <input type="submit" name="button" id="button" value="Update">

    </div>


    </div>

1 个解决方案

#1


3  

Change the data type to decimal(10,4)

将数据类型更改为十进制(10,4)

#1


3  

Change the data type to decimal(10,4)

将数据类型更改为十进制(10,4)