SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    prompting for user-intervention

    Say that I have a function where users can delete a certain value from a database...

    database:
    pages (id,subcat,txt,sections) sections foreign key to sections.id
    sections(id,titel)

    Lets say that we want to delete sectionid (12)...
    pagesid (1) and pagesid (2) both have a foreign link to sectionid (12).

    Now, how can I check if there is more than one page with the sectionid I want to delete, stop the function, ask if the user is sure... [yes/no] And either continue with the execution of the function, or stop the deletion of the value.

    The code I use is:
    PHP Code:
          $sql      "SELECT * FROM pages WHERE subcat = '$subcatid2'";
          
    $result mysql_query($sql);
          
    $rubids mysql_result($result,0,'sections'); 
          
          
    $rubidsnew str_replace("$sectionid,","",$sectionids);
          
    $rubidsnew1str_replace(",$sectionid","",$rubidsnew);
          
    $rubidsnew2str_replace("$sectionid","",$rubidsnew1);
            
          
    $update "UPDATE pages SET sections = '$rubidsnew2' WHERE subcat = '$subcatid2'";
          
    $res_up mysql_query($update);
          
          
    $sql1        "SELECT * FROM sections WHERE id = '$sectionid'";
          
    $result1  mysql_query($sql1);
          
    $rubtitel mysql_result($result1,0,'titel');
          
    // this is where I want to prompt the user if he is sure when there are more than one pages where the $sectionid exists

          
    $sql2     "DELETE FROM sections WHERE id = '$sectionid'";
          
    $result2  mysql_query($sql2);
          
          
    $sql3        "DELETE FROM links WHERE sections = '$sectionid'";
          
    $result3  mysql_query($sql3); 

  2. #2
    SitePoint Member
    Join Date
    May 2001
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not a good idea to split script by asking for user intervention. Yes/No should be asked on another page.
    Which in turn will redirect user back with more into.
    Like

    page 1 :
    when your script encounters this situation it
    redirects to another page (page 2) that asks yes/no question
    using some html form , and action script is targeted at
    page 1 that checks if the values is NO , then it doesn't proceed.
    Alex
    Certified CodeCharge Developer
    Develop database-connected web sites
    without coding: http://www.codecharge.com
    ASP, ASP.NET, PHP, JSP, Perl, ColdFusion


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •