How to save a specific id (problem) in another section?

Asked

Viewed 42 times

1

I’m trying to pass 1 unsolved problem to a section called "solved", ie someone sent from forms your problem you’re having, then in the admin I have all the problems that have already been created and I want to send to another section those that are already solved, that is, I have 2 sections, an "unsolved" call and another "solved" call, when clicking on a problem opens a modal only with information of the problem itself and within the modal want to have a button that when clicking passes such problem to the section of solved problems. To make a modal for each problem I used javascript from bootstrap, but I don’t know how to say that I just want to drag problem x to the other section. For this I created a function with sql to change the status of the problem to "solved" and also save the name of the administrator who solved it. I will show the code of the modal, of javascript and function.

<td><button data-toggle="modal" data-target="#dataModal" data-estado="<?php echo $data['estado'];?>" data-nome="<?php echo $data['nome'];?>" data-assunto="<?php echo $data['assunto'];?>" data-msg="<?php echo $data['msg'];?>" data-img="<?php echo $data['img'];?>" class="button1">Analisar</button></td>
<div class="modal-footer">
     <button onclick="alerta()" type="button" class="btn btn-default">Resolvido</button>
     <?php 
        $estado="Resolvido";
        $id= $data['id'];
        resolvido($estado,$_SESSION['UserNome'],$id);
     ?>
</div> 

In this part has a button, appears in front of each problem that button and when clicking opens the modal only with information of the problem x. And in the body of the modal has code php to try to do such a drag.

<script>
            $('#dataModal').on('show.bs.modal', function (event) {
                var botao = $(event.relatedTarget) // Botão que faz o modal abrir
                // Extract info from data-* attributes
                var id = botao.data('id')
                var estado = botao.data('estado') 
                var nome =  botao.data('nome')
                var assunto = botao.data('assunto')
                var msg = botao.data('msg')
                var img = botao.data('img')
                var modal = $(this)
                modal.find('.modal-body').html('<div class="container"> <i><h2 class="cor2">Estado ->' + estado + ' </h2><i> <h3 class="cor2">Nome ->'+ nome + '</h3> <h4 class="cor2">' + assunto + ' </h4> <p class="cor2">' + msg + ' </p> <img class="responsive" src="imagens/' + img + '" /> </div>');
            })
</script>

In this part has the script to open the modal only with the information of the problem x.

function resolvido($estado,$admin,$problemaId){
    global $connection;
    //Consulta
    $sql = "UPDATE `contacto` SET `estado` = '$estado', admin = '$admin' WHERE `id` = '$problemaId'";
    mysqli_query($connection,$sql);
}

In this last part has the function I called in the body of modal.

Please help me out.

1 answer

0

It’s very simple, you should create in your database a flame column status when the problem is created, this status will continue as Null. When you click the button that will move to solved, this button will send to a page that will Update the status of Null for resolvido. Then in a section you list only those with status´ = Null, the unsolved, and in another with status = resolvido.

  • My problem is how I get it to only change the status of the problem I open to solved so that it is moved to another section. I don’t know where to put the code to make that happen. I want to do this operation inside the modal, I only have 1 modal for all problems, I used javascript for this to happen

  • Create a link to the status update page where by parameter the id problem and update page change problem status to resolvido.

  • I’m sorry to ask this, but can you show an example? I’m a little confused with this, I’ve tried so much and I haven’t learned Javascript yet, if you can help me...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.