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 (); 
     
    }  

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.