Yes, there are many titles but I chose to explain the problem under this title because I could not find a solution in other titles :)
The database contains survey questions and records of the answers to this survey. I want to print the question titles of these records in the first column, and the answers under the columns.
For example,
question table id question_id question
answer table id question_id answer
I tried many methods but failed to show the answers in each line under the question headings.
Excel,
A - B - C .. etc.
1 - question_title question_title question_title .. etc.
2 - answer_title answer_title answer_title .. etc.
3 - answer_title answer_title answer_title .. etc.
4 - answer_title answer_title answer_title .. etc.
what have i done :)
$objPHPExcel = new PHPExcel();
$quest = $db->query("SELECT * FROM question WHERE question_id =1");
$answer = $db->query("SELECT * FROM answer WHERE question_id =1");
$objPHPExcel->setActiveSheetIndex(0);
$column = 'A';
foreach($quest as $rows){
$objPHPExcel->getActiveSheet()->SetCellValue($column.'1', $rows['question'],'UTF-8');
$column++;
}
$rowCount = 2;
$columns = 'A';
foreach($answer as $row){
$objPHPExcel->getActiveSheet()->SetCellValue($columns.'2', $row['answer'],'UTF-8');
$rowCount++;
$columns++;
}
i need to list the answers below the question result :