mcmuney Posted September 28, 2006 Share Posted September 28, 2006 I need to pull some data from my database and display a calculation:SELECT * FROM rate_score WHERE mem_id=1Then, I need to display the calculation result of (tot_score/tot_sum) Link to comment https://forums.phpfreaks.com/topic/22329-db-results/ Share on other sites More sharing options...
extrovertive Posted September 28, 2006 Share Posted September 28, 2006 SELECT (tot_score/tot_sum) as tot_cal FROM rate_score WHERE mem_id=1And just add more fields in your SELECT clause to select and display what you want. Link to comment https://forums.phpfreaks.com/topic/22329-db-results/#findComment-100036 Share on other sites More sharing options...
mcmuney Posted September 28, 2006 Author Share Posted September 28, 2006 Hmm, so I'm assuming I just use $tot_cal to display the calculated result? How would I specify the display format (ie 0.00 vs 0.0)? Link to comment https://forums.phpfreaks.com/topic/22329-db-results/#findComment-100055 Share on other sites More sharing options...
mcmuney Posted September 28, 2006 Author Share Posted September 28, 2006 What's wrong with this code?[code]<? $sql="SELECT round((sum_/count_),2) AS rate_score FROM sc_rate_score_avg WHERE scm_mem_id=".$rcset[0][scm_mem_id]."; $res = $db->select_data($sql);?><?=$rate_score?> [/code] Link to comment https://forums.phpfreaks.com/topic/22329-db-results/#findComment-100111 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.