| send price such as 1000.50 using a form
|
helenp

msg:4536597 | 4:54 pm on Jan 16, 2013 (gmt 0) | Hi, Been searching and trying, I need to insert a price in a form to later insert into a mysql column wich is decimal(10,2). The price needs to be like: 1000 or 1000.00 or 1000.50 Instead of 1 inputs wich looks more complicated to me I am trying to uso 2 inputs, wich I then join like this: $holidaycost = $price.".".$decimal; then I check the inputs with ctype_digit to check that only numbers where filled in. It works perfect, however if the second input is left empty then I need to convert the empty field to 0, wich I cant manage. Any ideas?
|
helenp

msg:4536674 | 9:59 pm on Jan 16, 2013 (gmt 0) | I think I should use one input and then format the price correctly. I ever used filters or regex, and I think this is the filters I need to change 1.001.50 to 1000.50 however it does not work, what am I doing wrong? $var = filter_var($price,FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); echo $var;
|
|
|