开发者

creating an alert and continue on this page after alert [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

I have an user table like this:-

               guid                | username |             password             | firstname | lastname  | location | emailad
dress |   userrole
-----------------------------------+----------+----------------------------------+-----------+-----------+----------+--------
------+---------------
 8024259764dc3e8ee0fb6f5.84107784  | james    | 827ccb0eea8a706c4c34a16891f84e7b | james     | bond      | NY       | ny@live
.com  | administrator
 18689183644dc3e91571a364.71859328 | saty     | 250cf8b51c773f3f8dc8b4be867a9a02 | saty      | john      | NY       | hk@fd.c
om    | administrator
 2644885344cecd6f2973b35.63257615  | admin    | 21232f297a57a5a743894a0e4a801fc3 | System    | Generated |          |
      | administrator
(3 rows)

now my postgre query for delete the row ....

$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&开发者_开发知识库gt;       
  <?php

(1)when I delete the user name one by one then delete occurs in my page userlist.php, I donot want to delete admin so i use username!= 'admin' in where condition as shown above. (2)now when I del any username(3 rows) from user table then alert occurs & it delete from userlist.php after that my page userlist.php is blank. Finaly when i refresh the page then my admin username seen..

so can anyone put the best condition in my coding. i donot want to refresh the page actualy i want my page continue after alert so plz help me


My guess is that you do not execute a SELECT-query after the delete. Make sure your list is BELOW the delete query, so your page would be something like

if($_GET['delete']) {
  // delete query
}

$sql = "SELECT * FROM";
// rest for getting the complete list.

This way you should get your refreshed list..

//edit: oh and perhaps adding return true; after the alert might continue execution the page, since javascript might block further execution on an alert (not sure if it returns false by default).


use this

$query = "select username from users where username='admin' and guid='".$guid."'";  
    $result = pg_query($conn, $query);
    AddLog("deleteUI.php","Query : ".$query,ERR_DEBUG_HIGH);
    while ($row = pg_fetch_array($result)) 

    //if (pg_affected_rows($result))
        {
            AddLog("deleteUI.php","Error !!! COMMIT",ERR_DEBUG_HIGH);
            pg_close($conn);
            ?>      
        <script type="text/javascript">            
        alert("Cannot delete the built-in admin user.");
        </script>           
        <?php 
        exit();
        } 

& delete query like that

$query = "delete from users where guid='".$guid."'"; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜