Jump to content


Photo

Splitting Queries or something


  • Please log in to reply
4 replies to this topic

#1 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 19 September 2006 - 06:14 PM

Okay I have a site that has different institutions and different advisors..  I need a list of the different advisors split up by their institutions and in alphabetical order...  Im not sure where to go from the code I have..  Now I am using smarty but all that works...

<?php
case 'list_all_advisors';
					
					/*
					$data = $turbo->get_all("SELECT advisors.fname, advisors.lname, advisors.advisor_id, count(*) as tot_rec, avg(total_score) as avg_score, recommendations.total_score FROM advisors, recommendations 
													WHERE advisors.advisor_id = recommendations.advisor_id GROUP BY advisor_id");
					///				
					*/
					
					$data = $turbo->get_all("SELECT advisors.fname, advisors.lname, advisors.advisor_id, advisors.institute_id, count(recommendations.rec_id) as tot_rec, avg(recommendations.total_score) as avg_score, recommendations.total_score FROM recommendations RIGHT JOIN advisors ON recommendations.advisor_id = advisors.advisor_id GROUP BY advisors.institute_id");
//$data = $turbo->get_all("SELECT advisors.fname, advisors.lname, advisors.advisor_id FROM advisors ORDER BY advisors.lname");
			

						$i = 0;
						foreach ($data as $this_adv){
							$adv_stats = $turbo->get_stats_adv($this_adv[advisor_id]);
							$data[$i][sd] = $adv_stats[sd];
							$data[$i][av] = $adv_stats[av];
			
														$i++;
						}
					
					$turbo->assign('rec', $rec);
					$turbo->assign('data',$data);
					//print_r($data);
					//print_r($adv_stats);
					$page = 'list_advisors';
			break;?>

I found the real cause of my problems and the post has been edited acordingly.
any help on this is greatly  appreciated...

#2 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 25 September 2006 - 03:31 PM

anyone know about this?

#3 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 25 September 2006 - 03:51 PM

I found the real cause of my problems and the post has been edited acordingly.


So what's the problem now then?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#4 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 28 September 2006 - 03:00 PM

Same thing -- Just didnt have the right piece of code before -- but now I do...

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 28 September 2006 - 06:10 PM

Substitute institution and advisor for letter and topic in this

http://www.phpfreaks....html#msg443126
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users