I am getting this error , Not able to make out what is going wrong , please help.
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ')' at line 1
SELECT GROUP_CONCAT(DISTINCT ud.userid) as id from pr_users_details ud INNER JOIN pr_users u ON ud.userid = u.id WHERE ud.status = '1' AND ()
My function looks like this:
function get_nomination_emailids($functions, $levels, $roles, $locations, $emails)
{
$SQL.="SELECT GROUP_CONCAT(DISTINCT ud.userid) as id from pr_users_details ud INNER JOIN pr_users u ON ud.userid = u.id WHERE ud.status = '1' ";
if(count($functions)>0)
{
$d = implode(",",$functions);
$whereand[] = " u.departmentid IN (".$d.") ";
}
if(count($levels)>0)
{
$d1 = implode(",",$levels);
$whereand[] = " ud.designation_id IN (".$d1.") ";
}
if(count($roles)>0)
{
$d2 = implode(",",$roles);
$whereand[] = " u.userroleid IN (".$d2.") ";
}
if(count($locations)>0)
{
$d3 = implode(",",$locations);
$whereand[] = " u.branchid IN (".$d3.") ";
}
if(count($emails)>0)
{
$d4 = implode(",",$emails);
$whereor[] = " ud.userid IN (".$d4.") ";
}
$whr = array();
if(isset($whereand))
$whr[] = " (".implode(" AND ",$whereand).") ";
if(isset($whereor))
$whr[] = " (".implode(" OR ",$whereor).") ";
if(count($whr > 0))
{
$SQL .= " AND (".implode(" OR ",$whr).") ";
}
$query = $this->db->query($SQL);
$return = $query->result_array();
return $return[0]['id'];
//print_r($return);die;
}
AND() remove in your query try this.
SELECT GROUP_CONCAT(DISTINCT ud.userid) as id from pr_users_details ud INNER JOIN pr_users u ON ud.userid = u.id WHERE ud.status = '1'
Related
I'm making a function that brings me the sum of the records in my database that meet 2 conditions.
i start like this
function cuentaticketspendienteempleado($conexion){
$pendientes = (mysqli_query($conexion, "SELECT COUNT(*) AS conteo FROM ticket ")) or die("Error mostrando tickets pendientes: ".mysqli_error($conexion));
$resultados = mysqli_fetch_row($pendientes);
return $resultados[0];
}
I need to add one more field to the account.
the ID department parameter which I want to assign to only tell me the tickets or reports of that department
using the previous function
When I'm trying to account for that user's tickets in that department using this function
function listTicketUnrevisedSupervisor($conexion, $id){
$consulta = mysqli_query($conexion, "SELECT *, COUNT(t.id) as contador_tickets, t.id as id_ticket, u.id as user_id, t.fecha_creacion as t_fcreacion, t.hora_creacion as t_hcreacion
FROM ticket as t
JOIN usuario AS u
ON t.id_usuario = u.id
WHERE t.status <> '3' AND u.id_departamento = ".$id."")
or die("Error listando Ticket: ".mysqli_error($conexion));
return $consulta;
}
i get this
error
Maybe is just the formatting of your post, but the * can't be used on a query when you are selecting other specific fields, you can use the function like this
function listTicketUnrevisedSupervisor($conexion, $id) {
$query = "SELECT t.field1, u.field_2, t.id as id_ticket, u.id as user_id, "
. "t.fecha_creacion as t_fcreacion, "
. "t.hora_creacion as t_hcreacion "
. "FROM ticket as t "
. "JOIN usuario AS u ON t.id_usuario = u.id "
. "WHERE t.status <> '3' "
. "AND u.id_departamento = " . $id . " "
. "ORDER BY t.id DESC ";
if($consulta = mysqli_query($conexion, $query)){
return $consulta;
} else {
die("Error listando Ticket: ".mysqli_error($conexion));
}
}
Or just select everything
function listTicketUnrevisedSupervisor($conexion, $id) {
$query = "SELECT * "
. "FROM ticket as t "
. "JOIN usuario AS u ON t.id_usuario = u.id "
. "WHERE t.status <> '3' "
. "AND u.id_departamento = " . $id . " "
. "ORDER BY t.id DESC ";
if($consulta = mysqli_query($conexion, $query)){
return $consulta;
} else {
die("Error listando Ticket: ".mysqli_error($conexion));
}
}
Counting the rows
$num_rows = mysqli_num_rows($consulta);
mysqli_query documentation (en)
Here you can check the documentation about mysqli_query (En EspaƱol Juan)
Hope my answer helps you.
Edit, fetch all the results
You can do it with a procedure like this one
function getTheAssocArrayOfMyQuery($consulta){
$return= array();
while ($row= mysqli_fetch_assoc($consulta)) {
array_push($return, $consulta);
}
return $return;
}
Or, using mysqli_fetch_all()
$this_is_the_array_i_will_use = mysqli_fetch_all($consulta,MYSQLI_ASSOC);
mysqli_fetch_all() manual
I am getting syntax error when I am using if conditions in the WHERE clause of my Mysql query. For example, if I put in WHERE 1 with only the condition like sector = 2, it is working. But when I put the if conditions, it is not working anymore.
$query= "SELECT
P.id
,P.price
,P.contract
,P.property_type
,P.sector
,P.title
,P.address
,P.bedrooms
,P.bathrooms
,P.price
,P.m2
,P.text_english
,P.photo_01
,P.utilities
,P.google_maps
,P.date
,CT.id
,CT.english_text
,PT.id
,PT.english
,C.cityname
,S.sectorname
,S.id
,O.ownername
,O.phone_one
,O.phone_two
,O.email
,O.notes
FROM properties P
JOIN contract CT
ON CT.id = P.contract
JOIN property_type PT
ON PT.id = P.property_type
JOIN city C
ON C.id = P.city
JOIN sector S
ON S.id = P.sector
JOIN owner O
ON O.id = P.owner WHERE 1";
if (!empty($sector)) { $query .= "AND P.sector = '$sector'"; }
if (!empty($property_type)) { $query .= " AND P.property_type = '$property_type'"; }
if (!empty($contract)) { $query .= " AND P.contract = '$contract'"; }
if (!empty($minimum_price)) { $query .= " AND P.price BETWEEN '$minimum_price' AND '$maximum_price'"; }
if (!empty($m2_from)) { $query .= " AND P.m2 BETWEEN '$m2_from' AND '$m2_until'"; }
if (!empty($bedrooms)) { $query .= " AND P.bedrooms = '$bedrooms'"; }
This is the error:
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'P.sector = 2
LIMIT 0, 30' at line 43' in
E:\xampp\htdocs\dolche\admin\class\pagination.php:451 Stack trace: #0
E:\xampp\htdocs\dolche\admin\class\pagination.php(451):
PDOStatement->execute() #1
E:\xampp\htdocs\dolche\admin\search.php(190): pagination->execute() #2
{main} thrown in E:\xampp\htdocs\dolche\admin\class\pagination.php on
line 451
Any help resolving this issue will be very welcome. Thanks!
You are missing a space between 1 and AND:
if (!empty($sector)) { $query .= "AND P.sector = '$sector'"; }
^^^^
HERE
Interestingly enough, you got it right everywhere else.
You have to add a space before your AND.
Try:
if (!empty($sector)) { $query .= " AND P.sector = '$sector'"; }
instead of
if (!empty($sector)) { $query .= "AND P.sector = '$sector'"; }
Add Space before AND P.sector = '$sector'
Change from
if (!empty($sector)) { $query .= "AND P.sector = '$sector'"; }
To
if (!empty($sector)) { $query .= " AND P.sector = '$sector'"; }
Please give space either:
ON O.id = P.owner WHERE 1 ";
or
if (!empty($sector)) { $query .= " AND P.sector = '$sector'"; }
Can someone help me convert the following code to Yii query? I would liek it to return array of type models with derived column
$sql = 'UPDATE jobs
RIGHT JOIN (
SELECT jobs.JOBNO,
round(details' . $type['type'] . '.' . $type['km'] . ' * sum(PRICE),2) AS JOBSVALUE
FROM jobs
JOIN projects ON jobs.PROJID = projects.PROJID
JOIN biditems ON projects.id = biditems.project_id
JOIN details' . $type['type'] . ' on jobs.JOBNO = details' . $type['type'] . '.JOBNO
WHERE jobs.PROJID = :pid
GROUP BY jobs.JOBNO
) AS temp ON jobs.JOBNO = temp.JOBNO
SET jobs.VALUE = JOBSVALUE';
$command=$connection->createCommand($sql);
$command->bindValue(":pid", $model->PROJID,PDO::PARAM_INT);
$command->execute();
$sql = "UPDATE jobs j
JOIN (
SELECT j.JOBNO, COUNT(l.JOBNO) AS numlis
FROM lineitems l
RIGHT JOIN jobs j ON j.JOBNO = l.JOBNO
WHERE j.PROJID = :pid
GROUP BY j.JOBNO
) t ON j.JOBNO = t.JOBNO
SET `VALUE` = 0, `EARNED` = 0
WHERE PROJID = :pid AND t.numlis = 0;";
$command=$connection->createCommand($sql);
$command->bindValue(":pid", $model->PROJID,PDO::PARAM_INT);
$command->execute();
1st attempt
$sql = "select jobs.JOBNO, round(details".$type['type'].".".$type['km']." * sum(PRICE),2) AS JOBSVALUE
from jobs
join projects on jobs.PROJID = projects.PROJID
join biditems on projects.id = biditems.project_id
join details".$type['type']." on jobs.JOBNO = details".$type['type'].".JOBNO
where jobs.PROJID = :pid
GROUP BY jobs.JOBNO";
$command=$connection->createCommand($sql);
$command->bindValue(":pid",$model->PROJID,PDO::PARAM_INT);
$result = $command->queryAll();
foreach ($result as $value) {
$job = Jobs::model()->findByPk($value['JOBNO']);
$job->VALUE = $value['JOBSVALUE'];
$job->save();
}
$sql = "SELECT j.JOBNO, COUNT(l.JOBNO) AS numlis
FROM lineitems l
RIGHT JOIN jobs j ON j.JOBNO = l.JOBNO
WHERE j.PROJID = :pid
GROUP BY j.JOBNO";
$command=$connection->createCommand($sql);
$command->bindValue(":pid",$model->PROJID,PDO::PARAM_INT);
$result = $command->queryAll();
foreach ($result as $value) {
if($value['numlis'] == 0){
$job = Jobs::model()->findByPk($value['JOBNO']);
$job->VALUE = 0;
$job->EARNED = 0;
$job->save();
}
}
Just literally following their documentation:
$job = Yii:app()->db
->createCommand()
->select(
'jobs.JOBNO, round(details'.$type['type'].'.'.$type['km'].' * sum(PRICE), 2)'
)
->join('projects', 'jobs.PROJID = projects.PROJID')
->join('biditems', 'projects.id = biditems.project_id')
->join('details'.$type['type'], 'jobs.JOBNO = details'.$type['type'].'.JOBNO')
->where('jobs.PROJID=:pid', array(':pid' = $model->PROJID))
->group('jobs.JOBNO')
->queryRow();
I have two variables in my WHERE statement. I cant seem to separate them with a space so i end up getting a syntax error. Thanks for the help.
(I am using codeigniter)
btw i have tried setting a $space variable, and putting spaces before the and, after setting both variables, and in the sql.
ERROR
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source_adusers.ad_account="Wolfs, Marc" GROUP BY rollout_systems.eam_user LIMIT ' at line 2
SELECT *, COUNT(rollout_systems.EAM_USER) as systems FROM rollout_systems LEFT JOIN source_adusers ON rollout_systems.EAM_User = source_adusers.ad_account WHERE rollout_systems.scope_ID = 3AND source_adusers.ad_account="Wolfs, Marc" GROUP BY rollout_systems.eam_user LIMIT 0,50
Line Number: 330
PHP
if ($this->session->userdata('scopeId') != NULL) {
$where1 = 'WHERE rollout_systems.scope_ID = '. $this->session->userdata('scopeId') . '';
} else {
redirect('/headquarters/home');;
}
if ($search) {
$where2 = ' AND rollout_systems.sys_name ="'.$search.'"';
} else {
$where2 = '';
}
$query = $this->db->query('SELECT * FROM rollout_systems LEFT JOIN source_adusers
ON rollout_systems.eam_user = source_adusers.ad_account '. $where1 .''. $where2 .' GROUP BY rollout_systems.sys_name LIMIT '.$limit.',50');
what if you keep the spaces and the AND in the $query, instead of building them into your where variables? Then your $where 2 just needs to work without affecting the query - thus 0=0.
if ($this->session->userdata('scopeId') != NULL) {
$where1 = 'WHERE rollout_systems.scope_ID = '. $this->session->userdata('scopeId') . '';
} else {
redirect('/headquarters/home');;
}
if ($search) {
$where2 = 'rollout_systems.sys_name ="'.$search.'"';
} else {
$where2 = '0=0';
}
$query = $this->db->query('SELECT * FROM rollout_systems LEFT JOIN source_adusers
ON rollout_systems.eam_user = source_adusers.ad_account '. $where1 .' and '. $where2 .' GROUP BY rollout_systems.sys_name LIMIT '.$limit.',50');
Just add a space between the two vars - '. $where1 .' '. $where2 .'
As pointed out by others you really should be escaping your user input using mysql_real_escape_string() or intval() if you are expecting an integer value. If you are using PDO or mysqli use prepared statements.
If $this->db is a PDO instance you could use -
$params = array();
if ($this->session->userdata('scopeId') != NULL) {
$where = 'WHERE rollout_systems.scope_ID = ?';
$params[] = $this->session->userdata('scopeId');
} else {
redirect('/headquarters/home');;
}
if ($search) {
$where .= ' AND rollout_systems.sys_name = ?';
$params[] = $search;
}
$sql = "SELECT * FROM rollout_systems
LEFT JOIN source_adusers ON rollout_systems.eam_user = source_adusers.ad_account
$where
GROUP BY rollout_systems.sys_name
LIMIT ?, 50";
$params[] = $limit;
$query = $this->db->prepare($sql);
$query->execute($params);
$where = array();
if ($this->session->userdata('scopeId') != NULL) {
// better to escape your parameter here unless you trust it totally
// judging by its name, it's user-provided data, so I wouldn't trust it
$where[] = 'rollout_systems.scope_ID = '. $this->session->userdata('scopeId');
} else {
redirect('/headquarters/home');
// you may need to exit here after redirection, depends on your implementation
}
if ($search) {
// once again don't forget to escape $search in real application
$where[] = "rollout_systems.sys_name = '" . $search . "'";
}
$query = $this->db->query("
SELECT
*
FROM
`rollout_systems`
LEFT JOIN
`source_adusers`
ON rollout_systems.eam_user = source_adusers.ad_account
WHERE
" . implode (' AND ', $where) . "
GROUP BY
rollout_systems.sys_name
LIMIT " . $limit /* escape it! */ . ",50"
);
You also have the option to use the PHP syntax
$sql = " blah blah {$my_var} {$my_other_var} ";
So i'm not that experienced in programming, and am working on some php.
My queries (not counting my broken if-else statements >_>), but when I submit 1 query (query2 for example), that works, it prints the results, as well as the results of another query7. How can I stop that?
Also if anyone has any clue where I failed in my if-else statements for the first query and query6, I'd appreciate some insight (they all use html submit buttons)
Thanks!
Here's my problem php code:
$lastName = $_POST['lastName'];
if ($_Post['lastName'] = "") {
$query = "SELECT c.*, s.speaker_year FROM Contact c, Speakers s WHERE s.Contact_con_id = c.con_id ";
} Else {
$query = "SELECT c.*, s.speaker_year FROM Contact c, Speakers s WHERE s.Contact_con_id = c.con_id
AND con_lname = ";
}
$query = $query . "'" . $lastName . "' ORDER BY con_lname;";
$rgroups = $_POST['rgroups'];
if ($_Post['rgroups'] = "") {
$query6 = "SELECT r.rev_groups_id, c.con_fname, c.con_lname, con_phone, rev_groups_pass, count(p.proposal_id)
FROM Review_Groups r JOIN Proposal p on r.rev_groups_id = p.Review_Groups_rev_groups_id
JOIN Presents px on px.Proposal_proposal_id = p.proposal_id
JOIN Contact c on px.Speakers_Contact_con_id = c.con_id
JOIN Reviewer rw on rw.Review_Groups_rev_groups_id = r.rev_groups_id
WHERE rw.reviewer_type = 'local'
AND r.rev_groups_id = ";
$query6 = $query6 . "'" . $rgroups . "' Group BY r.rev_groups_id;";}
Else {
$query6 = "SELECT r.rev_groups_id, c.con_fname, c.con_lname, con_phone, rev_groups_pass, count(p.proposal_id)
FROM Review_Groups r JOIN Proposal p on r.rev_groups_id = p.Review_Groups_rev_groups_id
JOIN Presents px on px.Proposal_proposal_id = p.proposal_id
JOIN Contact c on px.Speakers_Contact_con_id = c.con_id
JOIN Reviewer rw on rw.Review_Groups_rev_groups_id = r.rev_groups_id
WHERE rw.reviewer_type = 'local'
AND r.rev_groups_id = ";
$query6 = $query6 . "'" . $rgroups . "' ";}
$check = $_POST['check'];
$query7 = "Select c.con_fname, c.con_lname, s.Contact_con_id,
IF(s.Contact_con_id IS NULL, 'NO', 'YES')
From Contact c Left Join (Select Contact_con_id FROM Speakers
WHERE speaker_year = '". $check . "') As s
ON c.con_id = s.Contact_con_id";
$query7 = $query7 . " ORDER BY c.con_fname;";
(this is the code that prints on every result)
$average = $_POST['average'];
$query5 = "SELECT c.con_fname, r.Reviewer_Contact_con_id, question_id, AVG( DISTINCT question_score)
FROM Contact c, Individual_Review r
WHERE r.Reviewer_Contact_con_id = c.con_id
AND con_fname = ";
$query5 = $query5 . "'" . $average . "' GROUP BY r.Proposal_proposal_id;";
(example of working code. you can put in George next to con_fname to get a result)
// 1. Format your code with indents, etc.
// 2. Comment your code
// 3. Don't pass $_POST data straight to your sql.
// 4. Variables are case sensitive, including POST
$lastName = $_POST['lastName'];
if ($lastName = "") {
$query = "SELECT c.*, s.speaker_year FROM Contact c, Speakers s WHERE
s.Contact_con_id = c.con_id ";
}else{
$query = "SELECT c.*, s.speaker_year FROM Contact c, Speakers s WHERE
s.Contact_con_id = c.con_id
AND con_lname = ";
}
$query = $query . "'" . $lastName . "' ORDER BY con_lname;";
// if you did the first if, then this broke.
// Use:
// echo $query;
// to see what you have so far.
$query = "SELECT c.*, s.speaker_year FROM Contact c, Speakers s WHERE
s.Contact_con_id = c.con_id
AND con_lname = '".$lastName."' ORDER BY con_lname";
$rgroups = $_POST['rgroups'];
// you can go like $query .=
// you don't have to do $query = $query;
// so all of this could be:
$query6 = "SELECT r.rev_groups_id, c.con_fname, c.con_lname, con_phone, rev_groups_pass, count(p.proposal_id)
FROM Review_Groups r JOIN Proposal p on r.rev_groups_id = p.Review_Groups_rev_groups_id
JOIN Presents px on px.Proposal_proposal_id = p.proposal_id
JOIN Contact c on px.Speakers_Contact_con_id = c.con_id
JOIN Reviewer rw on rw.Review_Groups_rev_groups_id = r.rev_groups_id
WHERE rw.reviewer_type = 'local' ";
if ($_Post['rgroups'] = "") {
$query6 .= " AND r.rev_groups_id = '" . $rgroups . "' Group BY r.rev_groups_id;";
}else{
$query6 = "SELECT r.rev_groups_id, c.con_fname, c.con_lname, con_phone, rev_groups_pass, count(p.proposal_id)
FROM Review_Groups r JOIN Proposal p on r.rev_groups_id = p.Review_Groups_rev_groups_id
JOIN Presents px on px.Proposal_proposal_id = p.proposal_id
JOIN Contact c on px.Speakers_Contact_con_id = c.con_id
JOIN Reviewer rw on rw.Review_Groups_rev_groups_id = r.rev_groups_id
WHERE rw.reviewer_type = 'local'
AND r.rev_groups_id = '" . $rgroups . "' ";
}
$check = $_POST['check'];
You could add your $query7 in some if condition to avoid that
Note: I am dealing only with your PHP structure. I haven't looked at your SQL syntax at all. But I gave you the tools to see if SQL is returning what you think it should be returning.
<?PHP
// here are some functions for ya
function sqlarr($sql, $numass=MYSQL_BOTH) {
// MYSQL_NUM MYSQL_ASSOC MYSQL_BOTH
$got = array();
$result=mysql_query($sql) or die("$sql: " . mysql_error());
if(mysql_num_rows($result) == 0)
return $got;
mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result, $numass)) {
array_push($got, $row);
}
return $got;
}
// Sql fetch assoc
function sqlassoc($sql){
$query = mysql_query($sql) or die("$sql:". mysql_error());
$row = mysql_fetch_assoc($query);
return $row;
}
function sqlrow($sql){
$query = mysql_query($sql) or die("$sql:". mysql_error());
$row = mysql_fetch_row($query);
return $row;
}
function sqlquery($sql){
$query = mysql_query($sql) or die("$sql:". mysql_error());
return $row;
}
function printr( array $array, $label = '' ){
echo '<pre>'.$label;
print_r( $array );
echo '</pre>';
}
// This isn't the best, but it's better than nothing
// use PDO when you get more advanced
function makeSomewhatSafe($str){
return htmlspecialchars(stripslashes(strip_tags($str, '<p>')), ENT_QUOTES);
}
// good practice: initiate any variables you use at the beginning
// we're going to go ahead and strip them here too to try to avoid sql injection
$rgroups = makeSomewhatSafe($_POST['rgroups'] );
$lastName = makeSomewhatSafe( $_POST['lastName'] );
$query = NULL;
$speakerContactResulst = array();
$check = makeSomewhatSafe( $_POST['check'] );
$average = makeSomewhatSafe($_POST['average']);
// if($_Post['lastName'] = "") {
// we're going to see if it has a value
// another way to do this if your empty isn't working is to do
// if( strlen( $lastName ) > 0 ){
if( empty( $lastName ) ){
$query = "SELECT c.*, s.speaker_year FROM Contact c, Speakers s WHERE s.Contact_con_id = c.con_id ";
}else{
$query = "SELECT c.*, s.speaker_year FROM Contact c, Speakers s WHERE s.Contact_con_id = c.con_id
AND con_lname = ";
}
$query .= "'" . $lastName . "' ORDER BY con_lname";
echo 'This query states: '.$query.' <br /><br />';
$speakerContactResulst = sqlarr( $query );
printr( $speakerContactResulst, 'speakerContactResulst ');
if ( ! empty( $rgroups ) ){
$query = "SELECT r.rev_groups_id, c.con_fname, c.con_lname, con_phone, rev_groups_pass, count(p.proposal_id)
FROM Review_Groups r JOIN Proposal p on r.rev_groups_id = p.Review_Groups_rev_groups_id
JOIN Presents px on px.Proposal_proposal_id = p.proposal_id
JOIN Contact c on px.Speakers_Contact_con_id = c.con_id
JOIN Reviewer rw on rw.Review_Groups_rev_groups_id = r.rev_groups_id
WHERE rw.reviewer_type = 'local'
AND r.rev_groups_id = '" . $rgroups . "' Group BY r.rev_groups_id;";
}else{
// I dont know if you matters, but keep your else's more compact. Don't do like you had with the else on a new line
// str'; }
// else {
$query = "SELECT r.rev_groups_id, c.con_fname, c.con_lname, con_phone, rev_groups_pass, count(p.proposal_id)
FROM Review_Groups r JOIN Proposal p on r.rev_groups_id = p.Review_Groups_rev_groups_id
JOIN Presents px on px.Proposal_proposal_id = p.proposal_id
JOIN Contact c on px.Speakers_Contact_con_id = c.con_id
JOIN Reviewer rw on rw.Review_Groups_rev_groups_id = r.rev_groups_id
WHERE rw.reviewer_type = 'local'
AND r.rev_groups_id = '" . $rgroups . "' ";
}
$groupResults = sqlarr( $query );
printr( $groupResults, 'groupResults' );
$query = "Select c.con_fname, c.con_lname, s.Contact_con_id,
IF(s.Contact_con_id IS NULL, 'NO', 'YES')
From Contact c Left Join (Select Contact_con_id FROM Speakers
WHERE speaker_year = '". $check . "') As s
ON c.con_id = s.Contact_con_id ORDER BY c.con_fname;";
$checkResults = sqlarr( $query );
$query = "SELECT c.con_fname, r.Reviewer_Contact_con_id, question_id, AVG( DISTINCT question_score)
FROM Contact c, Individual_Review r
WHERE r.Reviewer_Contact_con_id = c.con_id
AND con_fname = '" . $average . "' GROUP BY r.Proposal_proposal_id;";
$averageResults = sqlarr( $query );
?>