Results 1 to 2 of 2

Thread: delete multiple registers of MySql DB

  1. #1
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default delete multiple registers of MySql DB

    I have this part of a form

    PHP Code:
    <select name="actas2[]" size="5" multiple>
                    <?
                        $sql 
    "select * from actas2 where area_ID = 1 order by year desc, number desc";
                        
    $query query($sql);
                        
    $conta mysql_num_rows($query);
                        for (
    $i=0;$i<$conta;$i++)
                        {
                            
    $arr mysql_fetch_array($query);
                            
    ?>
                      <option value="<? echo $arr["acta_ID"]; ?>"><? echo trata_data1($arr["dia"])." -> acta ".$arr["number"]." realizada em ".$arr["day"]." de ".trata_month($arr["month"])." de ".$arr["year"]; ?><? if ($arr['active'] == 'n') { ?> - Inactivo<? }?></option>
                            <?
                        
    }
                    
    ?>
                    
                      </select>

    And the php:

    PHP Code:
    /* APAGAR */
        
    if(isset($_POST['apagar']))
        {
            if(!isset(
    $_POST['actas2'])){ 
            
    $err 'Não escolheu um registo!'
                } 
                else{ 
                    if(
    is_array($_POST['actas2'])){ 
                        
    $id implode(',',$_POST['actas2']); 
                    } 
                    else{ 
                        
    $id $_POST['actas2']; 
                    } 
                    
    $sql "delete from actas2 where actas2_ID in (" $id ") and area_ID = 1"
                    
    $query query($sql);
                        if (
    $query == 1)
                        {
                            echo 
    "<script>alert('O documento foi apagada com sucesso.');</script>";
                        }
                        else
                        {
                            echo 
    "<script>alert('Problemas ao remover o documento.');</script>";
                        }                
                } 
            
        } 

    I don´t obtain the result that I want - delete one or more registries

  2. #2
    Join Date
    Feb 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Why are you using query($sql) and not mysql_query($sql) ?

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
  •