I am setting up a small data base and using phpMyAdmin to set the values for the fields, such as areas, bedrooms, prices ect. I have a field called "price" which will show the price of a propery, the question is..............what should I enter in the "Type" field and "Null" field to ensure the input displays with "£".
Any advice welcomed.

Mark

    Depends on what your intent with that currency value is.

    Personally, I'd leave it as a double (to store decimal values) or maybe even an integer (assuming any decimal place is multiplied out by its associated tens place). Reason for keeping it numeric: You might wish to do currency conversion. You might wish to add this field up and have a total (maybe total per week, month, year, etc).

    Now also remember the database is for data storage. Not for making data look pretty. That's PHP's job. To automatically add the £, you'll need to have PHP do it whenever it displays the price. Or, you can use MySQL's CONCAT() function to prefix the £ before the price value. That would work too.

      Thanks Astro,

      You have shed some light onto my question, The value will have no function.basically for now it will just display a price when the info is required. So can I assume that entering INT will be okay?

      Regards

      Mark

        Originally posted by cody44
        Thanks Astro,

        ...
        So can I assume that entering INT will be okay?

        I'm not sure what kind of numbers you'll be expecting. Just make sure INT is big enough to store the largest number you may have. Also keep in mind if you need to store decimal values or not. INT won't do decimal (unless you multiple by 10's to shift the decimal place).

          Write a Reply...