hossfly007 Posted April 6, 2007 Share Posted April 6, 2007 I am trying to count how much money a person has won and i cant find the right forumula for it. Here's an example: TABLE_MONEY >>ID >>DATE >>NAME >>MONEY_WON ID DATE NAME MONEY_WON 1 4/1 Jon 50.00 2 4/1 Tim 20.00 3 4/2 Jon 10.00 4 4/2 Tm 15.00 could someone show me a code that would tell me how much money Jon and Tim made? or a link to an example (if it's to complex) Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/ Share on other sites More sharing options...
per1os Posted April 6, 2007 Share Posted April 6, 2007 SELECT SUM(monkey_won) FROM table_money WHERE NAME IN('Jon', 'Tim'); Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222957 Share on other sites More sharing options...
hossfly007 Posted April 6, 2007 Author Share Posted April 6, 2007 frost your awesome man thanks alot Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222960 Share on other sites More sharing options...
hossfly007 Posted April 6, 2007 Author Share Posted April 6, 2007 ok one more thing, hate to be a newb again, but i cant get it to work... please help one more time $query = "SELECT SUM(money_total) as cash FROM TABLE_MONEY WHERE NAME IN('Jon')"; $r1 = mysql_fetch_array($query); $stats['cash'] = $r1['cash']; $text .= "{$stats['cash']}"; } Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222982 Share on other sites More sharing options...
MadTechie Posted April 6, 2007 Share Posted April 6, 2007 whats the error ? Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222986 Share on other sites More sharing options...
hossfly007 Posted April 6, 2007 Author Share Posted April 6, 2007 nothing shows up, it's just blank, yes there is data in the field. =] Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222989 Share on other sites More sharing options...
MadTechie Posted April 6, 2007 Share Posted April 6, 2007 can you post the part thats displays the results Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222992 Share on other sites More sharing options...
hossfly007 Posted April 6, 2007 Author Share Posted April 6, 2007 $query = "SELECT SUM(money_total) as cash FROM TABLE_MONEY WHERE NAME IN('Jon')"; $r1 = mysql_fetch_array($query); $stats['cash'] = $r1['cash']; print = "{$stats['cash']}"; } Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222995 Share on other sites More sharing options...
MadTechie Posted April 6, 2007 Share Posted April 6, 2007 humm try $query = "SELECT SUM(money_total) as cash FROM `TABLE_MONEY` WHERE `NAME` IN ('Jon')"; $r1 = mysql_fetch_array($query); print_r($r1); } Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-222996 Share on other sites More sharing options...
per1os Posted April 6, 2007 Share Posted April 6, 2007 I thought the column name was money_won... Link to comment https://forums.phpfreaks.com/topic/45895-how-to-count-number-within-a-db-field/#findComment-223007 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.