I have an array which stores Some section Names Like a,b,c and in each section there are questions like 'a' section contains q1,q2,q3. First i get those sections from myDB and then pass those section ID's to find questions query.
And Each Question has Score. Now what i want is the question which has 0 achieved score but have some applicable Score. i want those sections and their questions one by one.
This piece of code is working fine.
See Below
<?php
$sectionIDs = $obj->getSectionIDs($formatID); //section ID array starting from 225
$sectionNames = $obj->getSectionNames($formatID);
for($i=0; $i<count($sectionIDs); $i++)
{
$section_name_print_check ="" ;
$question_ids = $obj->getQuestionID($formatID,$sectionIDs[$i]);
$questionName = $obj->getQuestionName($formatID,$sectionIDs[$i]);
for($j=0; $j<count($question_ids); $j++)
{
$score_achieved = $obj->getScore_least($question_ids[$j],$formatID,$last_waveID,$received_ID);
$score_applicable = $obj->getScore_least_applicabe($question_ids[$j],$formatID,$last_waveID,$received_ID);
if($score_achieved == 0 && $score_applicable != 0)
{
if($section_name_print_check == "" )
{
$final_result_arr[$k]["SectionName"] = $sectionNames[$i];
$section_name_print_check = $sectionNames[$j];
}
$final_result_arr[$k]["QuestionName"] = $questionName[$j];
$k++;
}
}
}
?>
But in Retrieval i got some issues like extra table row. How can i get over rid of this problem. I got second echo each time. What i want is to get this echo only when new section comes.
Retrieval Code:
for($i=0; $i<count($final_result_arr); $i++)
{
echo '<tr style="background-color:#6F6; font-weight:bold;"><td style="width:700px;" colspan="4">'.$final_result_arr[$i]["SectionName"].'</td></tr>';
echo '<tr><td style="width:15px;">Sr.</td><td width="399px"></td><td style="width:143px;" align="center">Achieved Score</td><td style="width:143px;" align="center">Applicable Score</td></tr>';
echo '<tr><td style="width:15px;">'.++$serial.'</td><td style="width:399px;">'.$final_result_arr[$i]["QuestionName"].'</td><td align="center" style="width:143px;">0%</td><td align="center" style="width:143px;">100%</td></tr>';
echo '<tr><td colspan="5" style="height:25px;"></td></tr>';
}
The Output is:
Here i got Extra Table Row instead of getting one by one sections and question. What could be possible solution for this problem? Should i change my array into simple array or should i change my display section? Any Help! Thanks in Advance