刷新网页 代码

我要在一个网页上时时显示表study里的内容,例如, study里有三条记录,添加一条记录后,想让页面立即刷新到四条记录。

这是view页的内容:

 <form id="form1" name="form1" method="post" action="<?php echo $this->editFormAction?>">
    <table width="410" border="1" cellspacing="1" cellpadding="0">
      <tr>
        <td width="90" height="33" align="left" scope="col" class="color">病人症状:</td>
        <td width="320" align="left" scope="col" class="color1"><label for="textfield"></label>
        <input type="text" name="symptom" id="textfield" /> <span style="color:#FF3300">*</td>
      </tr>
      <tr>
        <td align="left" class="color">诊断日期:</td>
        <td align="left" class="color1"><label for="textfield3" ></label>
        <input type="text" name="date1" id="textfield3" class="textfield"/>
        —
        <label for="textfield4"></label>
        <input type="text" name="date2" id="textfield4" class="textfield"/>
        —
        <label for="textfield5"></label>
        <input type="text" name="date3" id="textfield5" class="textfield"/><span style="color:#FF3300">*</span></td>
      </tr>
      <tr>
        <td  align="left" class="color">诊断医师:</td>
        <td align="left"  class="color1"><label for="textfield"></label>
        <input type="text" name="doctor" id="textfield" /> <span style="color:#FF3300">*</td>
      </tr>
       <tr>
        <td  align="left" class="color">诊断结果:</td>
        <td align="left"  class="color1"><label for="textfield"></label>
        <input type="text" name="result" id="textfield" /></td>
      </tr>
      <tr>
        <td align="left" class="color">影像检查:</td>
        <td align="left" class="color1"> <input type="text" name="study_description" id="textfield" /> </td>
      </tr>
      <tr>
        <td align="left" class="color">开始时间:</td>
        <td align="left" class="color1"> <input type="text" name="study_starttime" id="textfield" /></td>
      </tr>
      <tr>
        <td align="left" class="color">结束时间:</td>
        <td align="left" class="color1"> <input type="text" name="study_endtime" id="textfield" /></td>
      </tr>
      <tr>
        <td align="left" class="color">检查医院:</td>
        <td align="left" class="color1"><label for="select"></label>
          <select name="hospitalID" id="select" class="select">
          <?php foreach ($this->rowset as $row):?>
          <option value="<?php echo $row['hospitalID'];?>" ><?php echo $row['hospitalname'];?></option>
          <?php endforeach;?>
        </select></td>
      </tr>
      <tr>
        <input name="patientID" type="hidden" id="id" value="<?php echo $this->row_rsPatient[0]['patientID'];?>">
        <td align="left" class="color1"><input type="submit" name="button" id="button" value="提交" /></td>
        <td align="left" class="color1"><input type="reset" name="button2" id="button2" value="重置" />
     </td></tr>
     <tr><td class="color" colspan="2">后面有<span style="color:#FF3300">*</span>号的输入框必须填写
      <input type="hidden" name="Study_insert" value="add"></input></td></tr>
    </table>
  </form>

以下是controller页面内的内容。

$this->view->diag_array=$study->fetchAll($where,$order)->toArray();
        $hospital=new hospital();
    $this->view->rowset=$hospital->fetchAll()->toArray();
    if((isset($_POST["Study_insert"]))&&($_POST["Study_insert"]=="add"))
    {
   
    $db=$study->getAdapter();
    $row=array(
    'symptom'=>GetSQLValueString($_POST['symptom'],"text"),
    'diagnosis_date'=>GetSQLValueString($_POST['date1'],"text").'-'.GetSQLValueString($_POST['date2'],"text").'-'.GetSQLValueString($_POST['date3'],"text"),
    'doctor'=>GetSQLValueString($_POST['doctor'],"text"),
    'result'=>GetSQLValueString($_POST['result'],"text"),
    'study_description'=>GetSQLValueString($_POST['study_description'],"text"),
    'study_starttime'=>GetSQLValueString($_POST['study_starttime'],"text"),
    'study_endtime'=>GetSQLValueString($_POST['study_endtime'],"text"),
    'patientID'=>GetSQLValueString($_POST['patientID'],"int"),
    'hospitalID'=>$_POST['hospitalID']
    );
    $this->view->Result1=$study->insert($row);
    }


如此方法,添加后,页面并不能马上显示添加后的内容。

应该在<form>之前添加如下几句:

 <?php if($this->Result1):?>
    <?php echo header(sprintf("refresh:0;url=$this->editFormAction"));?>
    <?php endif;?>

即,让页面刷新一下,则,可以显示出刚刚添加的内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值