我試圖更新everyting似乎是在查詢正確的數據庫記錄,但查詢不執行.... IM厭倦了這裏的概率低於 是我的代碼... .......所有的Mysql的更新查詢不能
<table width="409">
<tr>
<td><div align="right">Select Category</div></td>
<td><select name="cat">
<option value="0">--Select a Category--</option>
<?php
$qry=mysql_query("Select * from categories");
while($data=mysql_fetch_array($qry))
{
echo "<option value=".$data['catid'].">".$data['catname']."</option>";
}
?>
</select></td>
</tr>
<tr>
<td width="148"><div align="right">Category Name</div></td>
<td width="142"><input type="text" name="cname" /></td>
</tr>
<tr>
<td><div align="right">Category Discription</div></td>
<td><input type="text" name="cdescp" /></td>
</tr>
<tr>
<td><div align="right">Category Status</div></td>
<td><input type="text" name="cstatus" /></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><input type="submit" name="addcat" value="Update Category" /> <input type="reset" /></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['addcat']))
{
$catid=$_POST['cat'];
echo $catid;
$cnamei=$_POST['cname'];
$cdescpr=$_POST['cdescp'];
$cstat=$_POST['cstatus'];
$sql=mysql_query("Update categories SET catname=$cnamei,catdescr=$cdescpr, catstat=$cstat where catid=$catid");
echo $sql;
if($sql)
{
echo "<script>alert('Category Sucessfully Edited');</script>";
}
}
?>
脫離主題但重要;請注意'mysql_xxx()'函數已經過時。它們已被'mysqli_xxx()'funcs取代,並且PHP手冊**強烈建議切換。舊的funcs很可能會被棄用,並會從未來版本的PHP中刪除。 – Spudley