Jump to content

[SOLVED] Multiple Delete Query To Different Tables


Xtremer360

Recommended Posts

What I'm trying do in in the delete country in addition to the deleting country from the countries table I also need to have it go to the arenas table and have it find all the records that have the same country name as the one that's being deleted.

 

//Form was submitted - determine the form 
     if ( isset ( $_POST['deletecountry'] ) )
    {
        
        $country = mysql_real_escape_string($_POST['country']);
        $query = "DELETE FROM countries WHERE `country` =  '".$country."' LIMIT 1";  
    
        // Execute the query. 
        // Good.  This error checking method is recommended.
        if (@mysql_query ( $query )) 
        { 
            print '<p>The country has been deleted.</p>'; 
        } else 
        { 
            print '<p>Could not delete the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>'; 
        } 
         
        //mysql_close (); 
    }
    else if ( isset ( $_POST['editcountry'] ) ) 
    { 
        // Define the query. 
        $country = mysql_real_escape_string($_POST['country']);  
       $oldcountry = mysql_real_escape_string($_POST['oldcountry']); 
    
     $query = "UPDATE countries SET country = '$country' WHERE country = '$oldcountry'"; 
         
        // Execute the query. 
        // Good.  This error checking method is recommended.
        if (@mysql_query ( $query )) 
        { 
            print '<p>The country has been edited.</p>'; 
        } else 
        { 
            print '<p>Could not edit the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>'; 
        } 
         
        //mysql_close (); 
     
    }  

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.