Dear All
Need code to have 5 star ratings
event want 1.5, 2.5 etc (half star )
and way to store it in table
(how to get values so as to store in database)
5 replies to this topic
#1
Posted 23 January 2012 - 08:18 PM
|
|
|
#2
Posted 23 January 2012 - 10:31 PM
five stars is just to store a integer 0-5. if you want half steps, just do 0-10 and divide it to half when displaying, or just let it be stored and used as 0-10. this must be easiest.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#3
Posted 24 January 2012 - 03:36 AM
Why not you just store it with floating point and when needed, fetching it and by if-else you can use css.
#4
Posted 24 January 2012 - 01:04 PM
Floating point variables are always trickier, takes more memory and can end up in tiny rounding errors if used in some ways. I'd say, stay away from them if you can.
Example: 1/3 * 3 with floats is 0.9999999999 and if calculated correctly with ints 1, and those aren't equal.
You can easiest use a table converting (looking up) the number to the right html with a simple command instead of ridicilous if-else chains which is harder to follow.
Example: 1/3 * 3 with floats is 0.9999999999 and if calculated correctly with ints 1, and those aren't equal.
You can easiest use a table converting (looking up) the number to the right html with a simple command instead of ridicilous if-else chains which is harder to follow.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#5
Posted 24 January 2012 - 10:41 PM
We can also use number_format() before inserting mySQL that solve the problem of floating point and i am not use your second option instead of if-else. You can elaborate it. I am learning php :lol:
#6
Posted 25 January 2012 - 02:38 PM
I don't understand what you mean about my second thing?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









