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) Quote Link to comment 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. Quote Link to comment 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)? Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.