gpt4 book ai didi

php - 搜索 2 个输入字段 PHP MySQL

转载 作者:行者123 更新时间:2023-11-29 06:58:05 24 4
gpt4 key购买 nike

这是我的索引页,搜索字段位于其中。

index.php

      <form  method="post" action="search.php?go"  id="searchform"> 
<input type="text" name="Date">
<input type="submit" name="submit1" value="Search">
</form>

这是我的 search.php 页面

<?php

/* showing table after searching for date */

if(isset($_POST['submit'])){
if(isset($_GET['go'])){
$Date=$_POST['Date'];

$query= mysql_query("SELECT ID,Name,Location,Date,Category,LabourSupplier,InTime,OutTime,Day,DayRate,Salary,OTHours,OTrate,OTAmount,Allowance2,TotalSalary,Advance,SalaryToHand FROM attendance WHERE Date LIKE '%" . $Date . "%' ORDER BY location DESC, LabourSupplier ASC",$connection)
or die("Failed to query database" .mysql_error());

while($row=mysql_fetch_array($query)){

print "<tr>";
print "<td >" . $row['ID'] . "</td>";
print "<td >" . $row['Name'] . "</td>";
print "<td >" . $row['Location'] . "</td>";
print "<th >" . $row['Date'] . "</th>";
print "<td >" . $row['Category'] . "</td>";
print "<td >" . $row['LabourSupplier'] . "</td>";
print "<th >" . $row['InTime'] . "</th>";
print "<th >" . $row['OutTime'] . "</th>";
print "<th >" . $row['Day'] . "</th>";
print "<th >" . $row['DayRate'] . "</th>";
print "<th >" . $row['Salary'] . "</th>";
print "<th >" . $row['OTHours'] . "</th>";
print "<th >" . $row['OTrate'] . "</th>";
print "<th >" . $row['OTAmount'] . "</th>";
print "<th >" . $row['Allowance2'] . "</th>";
print "<th >" . $row['TotalSalary'] . "</th>";
print "<th >" . $row['Advance'] . "</th>";
print "<th>" . $row['SalaryToHand'] . "</th>";
print "</tr>";
}
}

}
print "</table>";

?>

我想添加另一个搜索字段,我可以在一个搜索按钮中搜索日期和位置,并获得满足两个位置广告日期的结果。

最佳答案

添加另一个输入

    <input  type="text" name="Location"> 

在 PHP 中

$Location=$_POST['Location'];

并在查询中

 $query= mysql_query("SELECT ID,Name,Location,Date,Category,LabourSupplier,InTime,OutTime,Day,DayRate,Salary,OTHours,OTrate,OTAmount,Allowance2,TotalSalary,Advance,SalaryToHand FROM attendance WHERE Date LIKE '%" . $Date . "%' AND Location LIKE '%" . $Location. "%' ORDER BY location DESC, LabourSupplier ASC",$connection)

关于php - 搜索 2 个输入字段 PHP MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44798219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com