2012-01-30 106 views
1

我在我的mysql數據庫中存儲了一些貨幣值,我現在將字段類型設置爲小數(10,2),這使我的價格爲2.22英鎊。我需要改變它,所以它的格式是1.3044英鎊。每次我輸入值1.3044將值1.30保存到數據庫時,是否有人知道顯示類似的正確類型? £1.3044更改mysql中的貨幣小數位

編輯>>>>

按照下面的答案,這現在工作,並保存在正確的格式的數據,問題是現在,由於某種原因,當它重新加載到表單字段後它將其更改爲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> 

回答

3

更改數據類型decimal(10,4)

+0

謝謝,這個工程現在,好樣的,如果我在1.3044鍵入它保存到數據庫中正確現在,如果我去到數據庫中的數據是正確的保存爲1.3044,但出於一些奇怪的原因,當它將數據加載回表單域時,它將其顯示爲1.30,即使在db中它是1.3044 – 2012-01-30 17:47:36

+0

@IainSimpson我的問題是,你如何在HTML中加載這個值?你使用什麼服務器端語言? – Ibu 2012-01-30 18:05:07