Jump to content

Archived

This topic is now archived and is closed to further replies.

mcmuney

DB Results

Recommended Posts

I need to pull some data from my database and display a calculation:

SELECT * FROM rate_score WHERE mem_id=1

Then, I need to display the calculation result of (tot_score/tot_sum)

Share this post


Link to post
Share on other sites
SELECT  (tot_score/tot_sum) as tot_cal FROM rate_score WHERE mem_id=1



And just add more fields in your SELECT clause to select and display what you want.

Share this post


Link to post
Share on other sites
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)?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.