我正在开发一个小型应用程序,我的controllers_viewpvcontroller
. 我正在尝试显示报告。用户可以决定年月,提交后,报表将显示在表单下的同一页面中。
这是我的控制器:
require_once ('library/Zend/Controller/Action.php');
class controllers_viewpvController extends Zend_Controller_Action {
public function init()
{
}
public function viewpvAction()
{
require_once 'models/PastPV.php';
$data = $this->getRequest()->getParams();
$year = $data['year'];
$month = $data['month'];
$pv = new PastPV();
$return = $pv->viewPV($year, $month); // this function is working fine.
$this->view->assign('values',$return);
}
public function getpvAction()
{
}
}
这是我的viewpv.phtml
:
<body>
<h1 id="h2"> Review</h1>
<br><div><center><form action="../Viewpv/viewpv" method="post" >
<h3>Payment Vouchers for : <select name="month">
<option value="null">(Month)</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
</select>
<select name="year">
<option value="null">(Year)</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
</select></h3>
<br><br>
<input type="submit" value="View">
</form></center>
</div></body>
<!--the codes to display the form are below-->
<?php
$return = $this->values;
if(!empty($return))
$tbl = '<table><tr><td>Document No</td></tr>';
while($data = $return->fetchRow()){ //here I think 'fetchRow()' may cause a problem.
//but that is not my question.
$tbl.='<tr><td>'.$data['docNo'].'</td></tr>';
}
$tbl.='</table>';
echo $tbl;
?>
当我尝试加载页面时,它给出了以下 php 错误:
Undefined index: year
Undefined index: month
此外,它给出了 Zend_Db_Statement_Exception, No parameters were bound
。我的感觉是,我还没有找到正确的方法来做到这一点。
请帮我解决一下这个。如果有更好的方法来实现这一点,请告诉我。