modal window from table

3

I have a table as shown in the image, and I want to show a modal window by clicking on the icon of each record, in the modal window it is necessary to search and display the details of the selected record as shown in the image ( is where I intend to arrive), for this I have the following:

Scheme of the table.

tentatively locate the modal window here so that it is only one for all rows but I'm not sure where the div modal

should be located
<div class="modal fade custom-modal" id="modalInvoiceView"  tabindex="-1" role="document" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <?php
        include_once("adm_invoice_view.php");
    ?>
</div>

<div class="pcoded-inner-content">
    <div class="main-body">
        <div class="page-wrapper">
            <!-- Page body start -->
            <div class="page-body">
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">                     
                        <div class="card mb-3">
                            <div class="card-block">
                                <table id="tblInvoice" class="table dt-responsive table-striped table-bordered nowrap js-table" style="width:100%">
                                    <thead>
                                        <tr>
                                            <th width="80" valign="middle">Numero</th>
                                            <th width="150" valign="middle">Fecha</th>
                                            <th width="150" valign="middle">Vence</th>
                                            <th width="500" valign="middle">Cliente</th>
                                            <th width="200" valign="middle">Almacen</th>
                                            <th width="150" valign="middle">Total</th>
                                            <th width="150" valign="middle">Saldo</th>
                                            <th width="100" valign="middle">Estado</th>
                                            <th width="150" valign="middle">Acciones</th>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                            <th width="80" valign="middle">Numero</th>
                                            <th width="150" valign="middle">Fecha</th>
                                            <th width="150" valign="middle">Vence</th>
                                            <th width="500" valign="middle">Cliente</th>
                                            <th width="200" valign="middle">Almacen</th>
                                            <th width="150" valign="middle">Total</th>
                                            <th width="150" valign="middle">Saldo</th>
                                            <th width="100" valign="middle">Estado</th>
                                            <th width="150" valign="middle">Acciones</th>
                                        </tr>
                                    </tfoot>
                                    <tbody>
                                        <!-- dataatables -->
                                    </tbody>
                                </table>
                            </div>  
                            <!-- end card-body -->                              
                        </div>
                        <!-- end card -->                   
                    </div>
                    <!-- end col -->    
                </div>
            <!-- end row -->    
            </div>
        </div>
    </div>
</div>

The filling of the table, this I do by means of ajax from a file that contains the SELECT to the MySql table, the line that is inserted in each record and that calls the modal window is

<a href="#" data-toggle="modal" data-target="#modalInvoiceView" data-invid="'. $row['inv_id'].'" title="Ver"><i class="icofont icofont-eye"></i></a>

File showing the window

The first thing to do is look for the record, here I have the first problem as I have here the id of the invoice ?, Notice that I used the attribute data-invid to send the id of the facura, as I recover it here ?, is there another method to send the id?

<?php
if (!empty($_REQUEST['invid'])){
    exit;
}

$regId = 939; //he puesto este numero aqui para que funcione el ejemplo

//selecciona el registro de factura
$sql = "SELECT * FROM invoice_master WHERE inv_id='$regId'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);

// muestra los datos organizados y un boton de cerrar la ventana modal...

For the example I have equaled the regId to 939 that is the id of any invoice so that all rows are going to show the same, only I did it to show the required result, if I remove it, the table will not it is shown and this makes me think that I do not have the modal window div well located ...

Thanks for your valuable help

    
asked by Juan Carlos 14.12.2018 в 15:12
source

1 answer

0

When you include include_once("adm_invoice_view.php"); you can not solve your concern. It is necessary that you have the structure of the modal in the view, but that you use an Ajax structure to make it easier.

See the answer to a very similar question that can help you.

You also have this other answer .

    
answered by 14.12.2018 / 16:06
source