xoligy Posted August 11, 2008 Share Posted August 11, 2008 Ok here is what im doing im finding out the percentage of x so the the formula is x=(0.25*gold) if i add that the the script thats fine! But i want the 0.25 in the db as there are going to be other results returned im a table like 35% etc etc can anyone help? Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/ Share on other sites More sharing options...
lemmin Posted August 11, 2008 Share Posted August 11, 2008 Can you be more specific? Are you asking how to alter your database? Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/#findComment-613819 Share on other sites More sharing options...
xoligy Posted August 11, 2008 Author Share Posted August 11, 2008 Sorry im trying to be quick as im using my mobile, basically i need to know how i can have the value 0.x in the db so i can call it to do the math right or if i have to do something else to get it to work Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/#findComment-613853 Share on other sites More sharing options...
discomatt Posted August 11, 2008 Share Posted August 11, 2008 Store it in a 0,2 float column. Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/#findComment-613894 Share on other sites More sharing options...
Barand Posted August 11, 2008 Share Posted August 11, 2008 I'd recommend DECIMAL rather than FLOAT pcent DECIMAL(4,2) NOT NULL DEFAULT 0 Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/#findComment-614000 Share on other sites More sharing options...
xoligy Posted August 11, 2008 Author Share Posted August 11, 2008 Thanks for that seems to me sorted the problem out is there a way i can show the % on the page for the user to see so they see 20 instead of just the 0.2? Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/#findComment-614057 Share on other sites More sharing options...
lemmin Posted August 11, 2008 Share Posted August 11, 2008 Like this? echo ($yourFloat*100) . "%"; Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/#findComment-614068 Share on other sites More sharing options...
xoligy Posted August 11, 2008 Author Share Posted August 11, 2008 Yeah like that god i feel like an idiot! Link to comment https://forums.phpfreaks.com/topic/119187-solved-percent-and-db/#findComment-614105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.