我有一个表单 dashboard.php
,它显示不同的记录(sampleid、类型、用户)。还有两个名为 aba.php
和 babab.php
的表单。 dashboard.php
中每条记录前面都有一个名为 Update 的按钮。
当我单击该按钮时,它应该根据类型的值打开特定的表单。我尝试了以下代码,但这总是打开 babab.php 表单。
我的代码有什么问题吗?
<?php
$type=$_GET['type'];
if ($type =="WOOD") {
$formid='aba-edit.php';}
elseif ($type=="BONE" OR 'CARBONATE' OR 'CELLULOSE'OR 'CHARCOL' OR 'CORAL'){
$formid='babab-edit.php';}
else {
echo "Under Construction";}
?>
<a onclick="window.open('aba-view.php?sampleid=<?php echo htmlentities($result->sampleid);?>','_blank','height=700,width=1200 top=200 left=350,location=no,toolbar=no,resizable=0, scrollbars=no')">
<button class="btn btn-primary"><i class="fa fa-edit "></i> VIEW</button>
<a onclick="window.open('<?php echo $formid ?> ?sampleid=<?php echo htmlentities($result->sampleid);?>','_blank','height=700,width=1200 top=200 left=350,location=no,toolbar=no,resizable=no, scrollbars=no')">
<button class="btn btn-primary"><i class="fa fa-edit "></i> UPDATE</button>
最佳答案
您的检查语法有错误:
elseif($type=="BONE" OR 'CARBONATE' OR 'CELLULOSE'OR 'CHARCOL' OR 'CORAL'){
应该是:
elseif($type=="BONE" OR $type=='CARBONATE' OR $type=='CELLULOSE'OR $type=='CHARCOL' OR $type=='CORAL'){
关于javascript - 根据从数据库获取的值打开表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58480884/