Jump to content


Photo

DB Results


  • Please log in to reply
3 replies to this topic

#1 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 28 September 2006 - 02:48 AM

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)

#2 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 28 September 2006 - 03:37 AM

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.


#3 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 28 September 2006 - 04:43 AM

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)?

#4 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 28 September 2006 - 08:33 AM

What's wrong with this 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?>
	





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users