Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Replace comma with dot

New Here ,
Mar 01, 2007 Mar 01, 2007

Copy link to clipboard

Copied

I have an update form to update an amount. The amount is stored in a database as a decimal 10,2. When I request the update form I get the amount as 1000,00 due to the fromatting I'm using. When I alter the amount in 1000,55 and send the input then everything before the comma gets updated and all that comes after is gone. If I type a dot instead of the comma then the amount is updated correctly. How can I do the update statement so that the comma gets replaced by a dot?

Update statement:

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "frmBudget")) {
$updateSQL = sprintf("UPDATE tbl_budgets SET budget=%s WHERE schoolid=%s",
GetSQLValueString($_POST['budget'], "double"),
GetSQLValueString($_POST['schoolid'], "int"));

Thanks in advance!

Robin
TOPICS
Server side applications

Views

348
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 01, 2007 Mar 01, 2007

Copy link to clipboard

Copied

LATEST
before the update statement

$_POST['budget'] = str_replace(",",".",$_POST['budget']);

This will replace each comma with a dot in $_POST['budget'];

When you display, do the opposite

echo str_replace(".",",",$recordset_name['budget']);


--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines