Skip navigation
Currently Being Moderated

salary. what phpmyadmin type - i used float

May 2, 2012 9:21 AM

i have used float 6,2 for a salary but it doesnt show the correct figure,

 

if the applicant inputs 25,000 i need it to come out like that or 120,000

 

thanks

jon

 
Replies
  • Currently Being Moderated
    May 2, 2012 10:34 AM   in reply to Jonathan Fortis

    Use decimal. See http://dev.mysql.com/doc/refman/5.5/en/fixed-point-types.html for more info.

     

    But basically, 5,2 would get you 999.99, 5 being the total size of the field. So for salary I use 9,2. Also the presentation is not in the database but in your code. Assuming you are using PHP take a look at  the number_format() function: http://php.net/manual/en/function.number-format.php.

     

    And if you want to point and click, search the exchange for "number formats". There are probably a few extensons available.

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 1:36 PM   in reply to Jonathan Fortis

    I don't understand your question. But if you need, you ahve have more then one decimal field.

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 2:28 PM   in reply to Jonathan Fortis

    No, of course not. You can't input characters into a numeric field. If you allow users to type in freeform, it will make it very difficult to create a meaningful query. If this is for salary range, I'd go what I think Stephen was suggesting; create two columns - one for min salary and one for max.

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 4:28 PM   in reply to Jonathan Fortis

    Sure, using a menu/dropdown to standardize the input is a good idea. But I still suggest two decimal fields for min and max if you are going to have users entering search criteria to find salaries within a certain range.

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 9:42 AM   in reply to Jonathan Fortis

    In my opinion this would simplify a search. How were to planning to allow a user to search for a salary range that was stored in a single column?

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 12:12 PM   in reply to Jonathan Fortis

    No, I mean what type of values are you expecting to be stored in the 'salary' database column, and what type of expression are you expected a user to enter when searching?

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 1:46 PM   in reply to Jonathan Fortis

    Let me try again. Please answer both questions:

     

    1) What type of values will be stored in the 'salary' database column(s)?

     

    2) What type of expression are you expected a user to enter when searching?

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 3:01 PM   in reply to Jonathan Fortis

    >so that is what people will be searching for and what will be stored

     

    What will be stored? You are showing 3 different examples. You would store all 3 for each job?

     

    Forget it - That concept simply won't work. First of all you can't store "+ 25000 - 30000" in a numeric database column; It's not numeric data. If you want to store salary ranges, then you need to create two columns - one for upper and one for lower.

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 7:26 PM   in reply to Jonathan Fortis

    If you want to do any type of calculation they'll have to be numbers. Actually you can calculate alpha numeric fields, but you won't get the results you expect.

     

    So control this in your form. You could let your users enter what they want, and strip any non-numeric chars from the fields before processing to your table. But this is the hard way.

     

    A better approach is to mask what they are entering. You can use Spry (javascript) within Dreamweaver for this. if you don't know anything about Javascript, this is the easy way. It's all point and click.

     

    Take a look at Insert > Spry. Also the help in DW is pretty good. Search on Spry and read up on it.

     

    So if you using a Spry "field" in your form (once you set the form up in the Properties Panel) your users would enter just a number; "205699" would appear (masked) as $2056.99. And Spry would only allow numbers in the $_POST[] var. Easy peay for processing.

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 4:19 PM   in reply to Jonathan Fortis

    >so thats why i suggested a dropdown to linit what goes in to the database

     

    You can use dropdowns to control the input. But most job postings list salary ranges. You can't have a dropdown for every possible salary range combination. So if you want the job listing to include salary ranges, you must use 2 columns.

     

    When a user is searching for a job, they would enter a desired salary and your SQL query would find any job within a matching salary range.

    You can also use Spry that Stephen is suggestion to validate the data and ensure it is numeric.

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 2:33 PM   in reply to Jonathan Fortis

    Dreamwever > Help > Spry Framework.

     

    What i would do is create a form, with two  "Spry" text fields. Using the properties panel you can set a mask and validation.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points