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