I am putting a whole HTML content inside a PHP variable and inside that content I am trying to echo some data fetching from database. But the problem is I cannot make the database query and echo the reuslt as the whole thing is wrapped with PHP and then HTML.(if it sounds confusing please check the code below.)
Is there any way to make the database query outside the PHP variable and echo it. Although I have already tried querying the database outside the variable but as it turned out this time >> $row['examdate']
is creating the problem. It shows an syntax error.
I am doing all these to generate PDF using DOMPDF. After getting the variable I will pass it to my controller to generate the pdf.
<?php $variable= " I need your help, I want to echo this <br>
<table id=\"table-6\" width=\"100%\">
<tr>
<th>Exam Date</th>
<th>Exam Type</th>
<th>Subject</th>
</tr>
$this->db->select('*');
$this->db->from('marks');
$this->db->where('studentid', $studentid);
$this->db->where('examdate >=', $daterange1);
$this->db->where('examdate <=', $daterange2);
$this->db->order_by('examdate','DESC');
$query = $this->db->get('');
if ($query->num_rows() > 0)
{
$row = $query->row_array();
<tr>
<td> echo $row['examdate']</td> ///****this line*****
<td>12</td>
<td>12</td>
<td>100</td>
</tr>
</table>
"; ?>-<< variable ends here