Jump to content

Splitting Queries or something


radar

Recommended Posts

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...

[code]
<?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;?>
[/code]

I found the real cause of my problems and the post has been edited acordingly.
any help on this is greatly  appreciated...
Link to comment
https://forums.phpfreaks.com/topic/21305-splitting-queries-or-something/
Share on other sites

Archived

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

×
×
  • Create New...

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.