gpt4 book ai didi

php - 查询未执行

转载 作者:行者123 更新时间:2023-11-30 22:42:02 27 4
gpt4 key购买 nike

我有一个搜索框来查找学生的信息。所有数据都显示良好,管理员可以从中更新状态,但是当管理员想要更新应用程序时,查询只是不执行。我不认为 sql 命令是错误的。我错过了什么吗?这是代码

public function searchApplicant()
{
echo '<table><form method="post">
<tr><td>
<input type=search name="studID" placeholder="ID Pelajar...">&nbsp;&nbsp;<button name="searchStud" type="submit">Cari</button>
</td></tr></form>
<tr><td>';
if(isset($_POST['searchStud']))
{
if(isset($_POST['studID']))
{
$studID=$_POST['studID'];
$query = mysql_query("SELECT * FROM `application` WHERE `studID` = '$studID'");
if(!$query)
{
echo mysql_error();
}
else
{
while($row = mysql_fetch_array($query))
{

$appID = $row['appID'];
$ic = $row['ic'];
$faculty = $row['faculty'];
$programme = $row['programme'];
$campus = $row['campus'];
$statusS = $row['statusS'];
$gender = $row['gender'];
$part = $row['part'];
$session = $row['session'];
$cgpa = $row['cgpa'];
$gpa = $row['gpa'];
$state = $row['state'];
$accountNo = $row['accountNo'];
$addressStud = $row['addressStud'];
$postcodeStud = $row['postcodeStud'];
$phoneS = $row['phoneS'];
$nameG = $row['nameG'];
$job = $row['job'];
$relationship = $row['relationship'];
$marriageStatus = $row['marriageStatus'];
$addressG = $row['addressG'];
$postcodeG = $row['postcodeG'];
$phoneG = $row['phoneG'];
$incomeG = $row['incomeG'];
$incomeM = $row['incomeM'];
$incomeO = $row['incomeO'];
$statusApplication = $row['statusApplication'];

echo '<form method="post">
<table border="0" cellspacing="2" cellpadding="2" width="705" style=" #fff;-webkit-box-shadow: 0 0 10px #660066; background:#ffffff;padding:0px;color:#848484; margin-top:50px;">
<tr>
<td><div align="left"><strong>No. Pelajar </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$studID.'</td>
</tr>
<tr>
<td><div align="left"><strong>No. K/P </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$ic.' </td>
</tr>

<tr>
<td><div align="left"><strong>Fakulti</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$faculty.'</td>
</tr>
<tr>
<td><div align="left"><strong>Kod Kursus </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$programme.'</td>
</tr>
<tr>
<td><div align="left"><strong>Kampus</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>UiTM Melaka Kampus Jasin</td>
</tr>
<tr>
<td><div align="left"><strong>Taraf Perkahwinan </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$statusS.'</td>
</tr>
<tr>
<td><div align="left"><strong>Semester/Bahagian</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$part.'</td>
</tr>
<tr>
<td><div align="left"><strong>Sesi</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$session.'</td>
</tr>
<tr>
<td><div align="left"><strong>CGPA Terkini </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$cgpa.'</td>
</tr>
<tr>
<td><div align="left"><strong>GPA Terkini </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$gpa.'</td>
</tr>
<tr>
<td><div align="left"><strong>Negeri Asal </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$state.'</td>
</tr>
<tr>
<td><div align="left"><strong>No. Akaun Bank Islam </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$accountNo.'</td>
</tr>
<tr>
<td>
<p align="left"><strong>Alamat Surat Menyurat</strong></p> <p align="left"><strong>(</strong><strong>Kolej/Rumah Sewa) </strong></p></td><td><div align="center"><strong>:</strong></div></td>
<td>'.$addressStud.'</td>
</tr>
<tr>
<td><div align="left"><strong>Poskod</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$postcodeStud.'</td>
</tr>
<tr>
<td><div align="left"><strong>No. Telefon </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$phoneS.'</td>
</tr>
<tr>
<td width="23%"><div align="left"><strong>Nama Ketua Keluarga </strong></div></td>
<td width="7%"><div align="center"><strong>:</strong></div></td>
<td width="70%">'.$nameG.'</td>
</tr>
<tr>
<td><div align="left"><strong>Pekerjaan</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$job.'</td>
</tr>
<tr>
<td><div align="left"><strong>Hubungan</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$relationship.' </td>
</tr>
<tr>
<td><div align="left"><strong>Status Perkahwinan </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$marriageStatus.'</td>
</tr>
<tr>
<td><div align="left"><strong>Alamat Surat Menyurat </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$addressG.'</td>
</tr>
<tr>
<td><div align="left"><strong>Poskod</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$postcodeG.'</td>
</tr>
<tr>
<td><div align="left"><strong>No. Telefon </strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$phoneG.'</td>
</tr>
<tr>
<td><div align="left"><strong>Pendapatan Bulanan </strong></div></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="left"><strong>Bapa/Penjaga</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$incomeG.'</td>
</tr>
<tr>
<td><div align="left"><strong>Ibu</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$incomeM.'</td>
</tr>
<tr>
<td><div align="left"><strong>Lain-lain</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>'.$incomeO.'</td>
</tr>

<tr>
<td><div align="left"><strong>Status Permohononan</strong></div></td>
<td><div align="center"><strong>:</strong></div></td>
<td>
<select name="statusApplication">
<option disabled="disabled" value="Dalam Proses" '.(($statusApplication=='Dalam Proses')?'selected="selected"':"").'>Dalam Proses</option>
<option value="Tidak Berjaya" '.(($statusApplication=='Tidak Berjaya')?'selected="selected"':"").'>Tidak Berjaya</option>
<option value="Berjaya" '.(($statusApplication=='Berjaya')?'selected="selected"':"").'>Berjaya</option>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="updateStatus" value="Kemaskini Status Permohonan"></td>
</tr>
</table>
</form>';

if(isset($_POST['updateStatus']))
{
if(isset($_POST['statusApplication'])){
$statusApplication = $_POST['statusApplication'];

$sql2 = "UPDATE `application`
SET `statusApplication`='$statusApplication'
WHERE `studID` = '$studID'";

$query2 = mysql_query($sql2);

if(!$query2)
echo mysql_error();
else
{
echo "<script type='text/javascript'>
alert('Status permohonan telah berjaya dikemaskini.');
window.location.href= 'searchApplicant.php';

</script>";
}
}
}
}
}}}}

最佳答案

你的逻辑有严重缺陷。你基本上有:

display form
show search results
update database

什么时候应该多一些

display form
if (search mode) {
run search
} else if (update mode) {
run update
}

关于php - 查询未执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30853456/

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