blackgold Posted August 3, 2008 Share Posted August 3, 2008 I'm a total newb, but here's my code. I have a cell colored a certain color if it's a win. I'm trying to calculate my win percentage. $test1 = mysql_query("SELECT COUNT(*) from mytable WHERE color=#ABD66F * '100'"; $test2 = mysql_fetch_row($test1); echo "$test2[0]"; Link to comment https://forums.phpfreaks.com/topic/117976-need-some-help-calculating-win-percentage-heres-my-code/ Share on other sites More sharing options...
cooldude832 Posted August 3, 2008 Share Posted August 3, 2008 um wow I don't even see table structure db structure or anything? we could guess at this but it just be pointless Link to comment https://forums.phpfreaks.com/topic/117976-need-some-help-calculating-win-percentage-heres-my-code/#findComment-606937 Share on other sites More sharing options...
Barand Posted August 3, 2008 Share Posted August 3, 2008 SELECT SUM(IF(color='#ABD66F', 1, 0)) * 100 / COUNT(*) FROM mytable Link to comment https://forums.phpfreaks.com/topic/117976-need-some-help-calculating-win-percentage-heres-my-code/#findComment-607015 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.