如果不满足第一个条件,我正在尝试使用php(if then else)语句打开另一个链接。但是这段代码不起作用,它只指向第一个条件。请在下面找到我的代码
表格的屏幕截图
注意:使用下面答案中的代码,但它只显示第一个表格按钮
<?php
$result = odbc_exec($conn,"SELECT tblParity.pxservice as service, tblPatients.Lname as Lname, tblPatients.mi as mi, tblPatients.Fname as fname, tblPatients.PhoneNum as PhoneNum, DATE_FORMAT(Bday,'%m / %d / %Y')as Bday, YEAR(now()) - YEAR(tblPatients.Bday) - ( DAYOFYEAR(now()) < DAYOFYEAR(tblPatients.Bday) ) as pxAge, tblPatients.PatientID as PatientID, DATE_FORMAT(tblOBGyne.obgyneDate,'%m-%d-%Y') as obgyneDate, TIME_FORMAT(tblOBGyne.obgyneTime, '%h:%i%p') as obgyneTime, tblParity.ParityID, tblOBGyne.OBGyneID
FROM tblPatients
JOIN tblParity ON tblPatients.PatientID = tblParity.PatientID
JOIN tblOBGyne ON tblParity.ParityID = tblOBGyne.ParityID
WHERE DATE_FORMAT(tblobgyne.obgyneDate, '%Y-%m-%d') = CURDATE() ORDER BY tblobgyne.obgyneTime ASC; ");
while($row = odbc_fetch_row($result))
{
?>
<tr>
<td class="center">
<?php
$service= odbc_result($result,"service");
$link = "";
$uServ = strtoupper($service);
if ($uServ=="GYNECOLOGY") $link = "recordgyne.php";
elseif ($uServ=="OBSTERICS") $link = "recordob.html";
?>
<?php if ($link !== "") { ?>
<a href="<?php echo $link."?pxid=".odbc_result($result,"PatientID"); ?>
&parid=<?php echo odbc_result($result,"ParityID"); ?>
&obgyneid=<?php echo odbc_result($result,"OBGyneID"); ?>"><span class="label label-default"><i class="icon-file-text"></i></span></a>
<?php } ?>
<a href="pxconsold.php?id=<?php echo odbc_result($result,"OBGyneID"); ?>"><span class="label label-warning"><i class="icon-edit"></i></span></a>
<a href="php/delete.php?id=<?php echo odbc_result($result,"OBGyneID"); ?>"><span class="label label-danger"><i class="icon-trash"></i></span></a>
</td>
<td hidden="text"><?php echo odbc_result($result,"OBGyneID"); ?></td>
<td><?php echo odbc_result($result,"Lname"); ?>
, <?php echo odbc_result($result,"Fname"); ?>
<?php echo odbc_result($result,"mi"); ?></td>
<td><?php echo odbc_result($result,"Bday");?></td>
<td><?php echo odbc_result($result,"pxAge"); ?></td>
<td><?php echo odbc_result($result,"PhoneNum"); ?></td>
<td ><?php echo odbc_result($result,"service"); ?></td>
<td><?php echo odbc_result($result,"obgyneTime"); ?></td>
</tr>
<?php
}
odbc_close($conn);// Closes ODBC Connection to DB
?>
答案 0 :(得分:0)
您的if语法不正确。
if($service == 'Gynecology' or $service == 'GYNECOLOGY'): ?>
<a href="recordgyne.php?pxid=<?php echo odbc_result($result,"PatientID"); ?>
&parid=<?php echo odbc_result($result,"ParityID"); ?>
&obgyneid=<?php echo odbc_result($result,"OBGyneID"); ?>"><span class="label label-default"><i class="icon-file-text"></i></span></a>
<?php elseif($service == 'Obstetrics' or $service == 'OBSTERICS'): ?>
<a href="recordob.html?pxid=<?php echo odbc_result($result,"PatientID"); ?>
&parid=<?php echo odbc_result($result,"ParityID"); ?>
&obgyneid=<?php echo odbc_result($result,"OBGyneID"); ?>"><span class="label label-success"><i class="icon-file-text"></i></span></a>
<?php endif; ?>
答案 1 :(得分:0)
=
是作业==
是对相等的测试假设没有链接,如果妇科和产科都没有尝试这个:
$link = "";
$uServ = strtoupper($service);
if ($uServ=="GYNECOLOGY") $link = "recordgyne.php";
elseif ($uServ=="OBSTETRICS") $link = "recordob.html";
<?php if ($link !== "") {
$link.="?pxid=".odbc_result($result,"PatientID")."&parid=".odbc_result($result,"ParityID")."&obgyneid=".odbc_result($result,"OBGyneID");
?>
<a href="<?= $link ?>"><span class="label label-default"><i class="icon-file-text"></i></span></a>
<?php } ?>