我将整个HTML内容放入PHP变量中,并在该内容中尝试回显从数据库获取的某些数据。但问题是我无法进行数据库查询和回显reuslt,因为整个事情都是用PHP和HTML封装的(如果听起来令人困惑,请查看下面的代码。)如何在使用PHP封装HTML时在HTML内写入PHP
有什么办法可以让数据库在PHP变量之外查询并回显它。尽管我已经试过查询变量之外的数据库,但是这次发现>>$row['examdate']
正在创建这个问题。它显示一个语法错误。
我正在做所有这些使用DOMPDF生成PDF。获取变量后,我将它传递给我的控制器来生成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
好奇你是怎么不工作的代码,这样巨量?为什么作为一个新手,你不检查它是否在每行之后都有效?!?!?!?!在这种情况下,你只有一行你有问题,但现在你有20 – zerkms 2011-12-31 07:03:56
使用[HEREDOC语法](http://www.php.net/manual/en/language.types.string.php# language.types.string.syntax.heredoc)用于大型字符串变量。 – mario 2011-12-31 07:07:42
可能的重复[是否有理由在PHP中使用Heredoc?](http://stackoverflow.com/questions/5673269/is-there-a-reason-to-use-heredoc-in-php) – mario 2011-12-31 07:09:28