後,我有一個用戶表是這樣的: -創建警報並繼續在此頁上的警報
guid | username | password | firstname | lastname | location | emailad
dress | userrole
-----------------------------------+----------+----------------------------------+-----------+-----------+----------+--------
------+---------------
8024259764dc3e8ee0fb6f5.84107784 | james | 827ccb0eea8a706c4c34a16891f84e7b | james | bond | NY | [email protected]
.com | administrator
18689183644dc3e91571a364.71859328 | saty | 250cf8b51c773f3f8dc8b4be867a9a02 | saty | john | NY | [email protected]
om | administrator
2644885344cecd6f2973b35.63257615 | admin | 21232f297a57a5a743894a0e4a801fc3 | System | Generated | |
| administrator
(3 rows)
現在我postgre查詢刪除行....
$query = "delete from users where username!= 'admin' and guid='".$guid."'";
$result = pg_query($conn, $query);
?>
<script type="text/javascript">
alert("Cannot delete this .\n It is system generated(s).");
</script>
<?php
(1 )當我逐個刪除用戶名然後刪除發生在我的頁面userlist.php,我不想刪除管理員,所以我使用username!= 'admin'
在哪裏條件如上所示。 (2)現在當我從用戶表中刪除任何用戶名(3行)然後發生警報&它刪除userlist.php後,我的頁面userlist.php爲空。最後,當我刷新頁面,然後看到我的管理員用戶名..
所以任何人都可以把最好的條件放在我的編碼中。 我不想刷新頁面實際上我希望我的頁面繼續提醒後,所以PLZ幫助我
可能重複(HTTP:// stackoverflow.com/questions/810180/how-to-prevent-deletion-of-the-first-row-in-table-postgresql) – 2011-05-06 13:35:04
這看起來驚人地類似於: http://stackoverflow.com/questions/5908897/查詢換我-F irst-row-admin-for-never-delete and http://stackoverflow.com/questions/810180/how-to-prevent-deletion-of-the-first-row-in-table-postgresql – 2011-05-06 13:36:16