这是我的代码。但是当我单击生成的任何按钮时,数据库中有多个pdf文件时,它将在iframe中显示相同的pdf文件。
<table>
<?php
$sql_ord=pg_query($conn,"select * from pp_upload where doc_type='".$doc_type."' AND regcase_type='".$case."' AND reg_no='".$regno."' AND reg_year='".$regyear."' AND judge_code='".$row_judge_c[0]."'") or die ('Query failed: '. pg_last_error());
while($row_ord=pg_fetch_array($sql_ord))
{
?>
<tr>
<td>
<input type="hidden" name="docview" id="docview[]" value="<?php echo $row_ord['path']; ?>">
</td>
<td>
<input type="button" value="View" onclick="openPdf(document.getElementById('docview[]').value)"/>
</td>
</tr>
<?php
}
?>
</table>
<iframe id="myFrame" style="display:none" width="800px" height="600px"></iframe>
<script type="text/javascript">
function openPdf(docview)
{
var omyFrame = document.getElementById("myFrame");
omyFrame.style.display="block";
omyFrame.src =docview;
}
</script>