Page 1 of 1
Pass Numeric Values From Form
Posted: Fri Aug 12, 2011 9:59 am
by edziffel
Need to pass numeric values from user input in dynamically created drop down lists which are then posted. Because they are dynamically generated, they can not be set to a session variable before use. From what I can tell you can only pass non-numeric data via post. I need to be able to pass numeric strings i.e. (9,2) think defining length of say a DECIMAL in a MySQL column, (15, 5, xxx, ..., n) as well as just (n).
What are my options for this?
Re: Pass Numeric Values From Form
Posted: Fri Aug 12, 2011 11:26 am
by flying_circus
Correct, any post, get, or cookie data transmitted over HTTP will be a string.
However, if you are passing the data through a POST, you can cast the data to the type that you want before say, inserting into a database.
I dont understand this comment, it sounds like a conflicting ideology:
edziffel wrote:I need to be able to pass numeric strings i.e. (9,2)
a numeric string is just a string as far as I am concerned.
Re: Pass Numeric Values From Form
Posted: Fri Aug 12, 2011 12:26 pm
by social_experiment
The Manual wrote:Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part.
You can also use is_numeric() to see if value received from G,P or C (get, post or cookie) is indeed a numeric value.
Re: Pass Numeric Values From Form
Posted: Fri Aug 12, 2011 3:12 pm
by flying_circus
social_experiment wrote:The Manual wrote:Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part.
Huh, well I learned something new
