简体   繁体   English

用十进制更新MySQL记录

[英]Updating MySQL record with a decimal

I can not figure out how to update the record with aa decimal. 我不知道如何用十进制更新记录。 For example. 例如。 For room width, I need to add 4.2 but it rounds to 4. Please help 对于房间宽度,我需要添加4.2,但是四舍五入到4。请帮助

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == $form_number)) {
$updateSQL = sprintf("UPDATE pano_table817 SET room_name=%s, room_width=%s, 
room_length=%s, delete_image=%s, is_pano=%s, outside_image=%s, 
floor_level=%s 
WHERE pano_id=%s",
                   GetSQLValueString($_POST['room_name'], "text"),
                   GetSQLValueString($_POST['room_width'],"numeric"),
                    GetSQLValueString($_POST['room_length'],"numeric"),
                    GetSQLValueString($_POST['delete_image'],"int"),
                    GetSQLValueString($_POST['is_pano'],"int"),
                    GetSQLValueString($_POST['outside_image'],"int"),
                    GetSQLValueString($_POST['floor_level'],"int"),
                   GetSQLValueString($_POST['pano_id'], "int")); 
mysql_select_db($database_ndctour, $ndctour);
$Result1 = mysql_query($updateSQL, $ndctour) or die(mysql_error());

HTML Form: HTML表单:

<input type="text" name="room_width" class="input-text-integer" value="<?php 
echo $row_uploaded_images['room_width']?>">ft</td><td>
<input type="text" name="room_length" class="input-text-integer" value="<?
php echo $row_uploaded_images['room_length']?>">ft</td><td>

check your field definition for room_width, it needs to accept decimals with (in your case, with this specific example in mind) at least 1 decimal, and 2 total numbers. 检查room_width的字段定义,它需要接受十进制数(在您的情况下,请牢记此特定示例),其中至少应包含1个小数和2个总数。 This would give you 这会给你

DECIMAL(2,1)

give yourself a little room, and use something along the lines of 给自己一个小空间,并使用一些类似的方法

DECIMAL(4,2)

if you did have a valid mysql definition, let me know and ill look more in depth 如果您确实有一个有效的mysql定义,请让我知道,并且病情较深

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM