File: /var/www/sectest.concertium.com/public_bak/wp-content/themes/dt-the7/dt_scroing_result.php
<?php
global $wpdb;
$all_contact_details = $wpdb->get_results( "SELECT * FROM `dt_scoring_contactdetails_master` WHERE i_id >0 ORDER BY dt_created_on DESC" );
if(!empty($all_contact_details))
{
?>
<table width="100%" border="1">
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
<th>Phone No</th>
<th>Total Score</th>
<?php
$question_type = get_terms( 'scoring-category', 'orderby=id&hide_empty=0&parent=0' );
if(!empty($question_type))
{
foreach($question_type as $question_type_val)
{
?>
<th><?php echo $question_type_val->name;?></th>
<?php
}
}
?>
<th>Date</th>
</tr>
<?php
$count = 1;
foreach($all_contact_details as $all_contact_details_val)
{
$contact_id = $all_contact_details_val->i_id;
$all_answered_marks = $wpdb->get_results( "SELECT SUM(s_answer_marks) as total_score FROM `dt_scoring_details` WHERE i_reviewer_id = ".$contact_id."" );
?>
<tr>
<td><?php echo $count;?></td>
<td><?php echo $all_contact_details_val->s_name;?></td>
<td><?php echo $all_contact_details_val->s_email;?></td>
<td><?php echo $all_contact_details_val->s_phone_number;?></td>
<td style="text-align:center;"><?php echo $all_answered_marks[0]->total_score;?></td>
<?php
if(!empty($question_type))
{
foreach($question_type as $question_type_val)
{
$question_type_id = $question_type_val->term_id;
$all_answered_marks_categorywise = $wpdb->get_results( "SELECT SUM(s_answer_marks) as total FROM `dt_scoring_details` WHERE i_reviewer_id = ".$contact_id." AND i_question_type_id = ".$question_type_id."" );
if(!empty($all_answered_marks_categorywise))
{
$marks = $all_answered_marks_categorywise[0]->total;
}
else
{
$marks = 0;
}
?>
<td style="text-align:center;"><?php echo $marks;?></td>
<?php
}
}
?>
<td><?php echo date('m-d-Y',strtotime($all_contact_details_val->dt_created_on));?></td>
</tr>
<?php
$count++;
}
?>
</table>
<?php
}
?>