使用 php 搜索多个文本框
我正在尝试使用 php 使用多个文本框搜索此代码,并且我正在使用 orcle 数据库,但此代码不起作用。并且任何人都让我知道为什么此代码不使用多个文本框字段搜索的问题是什么,并且我收到错误警告:oci_execute():ORA-00920:无效的关系运算符
请检查.....我的代码..
<form action="Optr_Search.php" method="get">
<table width="500" border="0" align="center">
<tr>
<td width="203"><div align="right"><strong>Operator ID:</strong>
</div></td>
<td width="148"><input type="text" name="OPRID" /></td>
</tr>
<tr>
<td><div align="right"><strong>Operator Name:</strong></div></td>
<td><input type="text" name="OPRDEFNDESC" /></td>
</tr>
<tr>
<td><div align="right"><strong>Person ID:</strong></div></td>
<td><input type="text" name="EMPLID" /></td>
</tr>
<tr>
<td><div align="right"><strong>Email ID:</strong></div></td>
<td><input type="text" name="EMAILID" /></td>
</tr>
<tr>
<td colspan="2">
<div align ="center">
</br>
<input type="submit" align ="middle"value="Search" name ="submit" />
</div>
</td>
</tr>
</table>
</form>
<?php
$ora_conn = oci_connect('system','oracle','//localhost/XE');
if(!$ora_conn)
{
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else
{
print "You are connected to the database!<br/>";
}
if(isset($_POST['submit']))
{
$optid = $_POST['OPRID'];
$optdec = $_POST['OPRDEFNDESC'];
$empid = $_POST['EMPLID'];
$empmail = $_POST['EMAILID'];
$query = "SELECT * FROM OPERATOR WHERE 1";
if(isset($optid) && $optid != '') {
$query .= " And OPRID Like'%$optid%'";
}
if(isset($optdec) && $optdec != '') {
$query .= " OR OPRDEFNDESC Like'%$optdec%'";
}
if(isset($empid) && $empid != '') {
$query .= " OR EMPLID Like '%$empid%'";
}
if(isset($empmail) && $empmail != '') {
$query .= " OR EMAILID Like '%$empmail%'";
}
$objParse = oci_parse($ora_conn,$query);
$objResult = oci_execute ($objParse, OCI_DEFAULT);
?>
<table width="500" border="1" align="center">
<tr>
<th width="98"> <div align="center">Operator ID</div></th>
<th width="98"> <div align="center">Operator Name</div></th>
<th width="98"> <div align="center">Person ID</div></th>
<th width="98"> <div align="center">Email ID</div></th>
<th width="98"> <div align="center">Edit</div></th>
</tr>
<?php
if(oci_execute($objParse,OCI_DEFAULT)){
while($objResult = oci_fetch_array($objParse, OCI_RETURN_NULLS+OCI_ASSOC))
{
?>
<tr>
<td><div align="center"><?=$objResult["OPRID"];?></div></td>
<td><?=$objResult["OPRDEFNDESC"];?></td>
<td><?=$objResult["EMPLID"];?></td>
<td><div align="center"><?=$objResult["EMAILID"];?></div></td>
<td align="center"><a href="Optr_Edit.php?OprID=<?=$objResult["OPRID"];?>">Edit</a>
</td>
</tr>
<?
}
?>
</table>
<?
oci_free_statement($objParse);
oci_close($ora_conn);
}
?>