无需js即可删除js文件和表单-Javascript / Jquery

时间:2018-11-04 19:16:06

标签: javascript jquery forms

那么我不明白为什么,这段代码显示了一个表格,该表格以复选框的形式并按下特定的Excel按钮,提取了该特定id的所有值,直到这里没有任何内容,放置代码:

<main>
<?php
include '../../connessione.php';
$query_string = "SELECT * FROM clienti";
$query = mysqli_query($connessione, $query_string);
?>

<div class="container-fluid text-center">
<div class="row">
<div style="padding-top: 15px;" class="col-md-6">
<form method="post" action="excel.php">
<input type="submit" name="export" class="btnSearch" value="Estrai in excel" />
</form>
</div>

<div style="padding-top: 15px;" class="col-md-6">
<form action="excel_specifico.php" method="post">
<input style="margin-left: 20px;" type="submit" value="Excel Specifico" class='btnSearch'>
</div>
<div  class="col-md-12">

<table id="dtBasicExample" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
<thead>
<tr>
<th class="th-sm">ID
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Nome
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Cognome
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Email
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Telefono
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Modifica
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
<th class="th-sm">Elimina
<i class="fa fa-sort float-right" aria-hidden="true"></i>
</th>
</thead>
<tbody>

<?php
while($row = mysqli_fetch_assoc($query)){ ?>
<tr>
<td>        
<!-- Material unchecked -->
<div class="form-check">
<?php $cliente_id = $row["cliente_id"]; ?>
<?php echo "<input  type='checkbox' name='estrai[$cliente_id]' value='1' class='form-check-input' id='$cliente_id'>  " ?>
<?php echo "<label class='form-check-label' for='$cliente_id'</label>"; ?> 
</div>
</td>
<td><?php echo $row['nome'] ;?></td>
<td><?php echo $row['cognome'] ;?></td>
<td><?php echo $row['email'] ;?></td>
<td><?php echo $row['telefono'] ;?></td>
<td style="text-align: center;"><a href="#"><?php echo "<a href='paginadettaglio.php?cliente_id={$row['cliente_id']}' class='btn btn-sm btn-warning '>Modifica</a><br>";?></a></td>
<td style="text-align: center;"><a href="#elimina<?php echo $row['cliente_id']; ?>" data-toggle="modal" class="btn btn-sm btn-danger "><span class="glyphicon glyphicon-trash"></span> ELIMINA</a></td>
<?php include('modali.php'); ?>
</tr>
<?php } ?>

</tfoot>
</table>
</form>
</div>
</div> 
</main>
<script>
// Basic example
$(document).ready(function () {
$('#dtBasicExample').DataTable();
$('.dataTables_length').addClass('bs-select');
});
</script>
<script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
<script src="../../js/pagination.js"></script>
<script type="text/javascript" src="../../js/popper.min.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/mdb.min.js"></script>
<script>
$(".button-collapse").sideNav();
new WOW().init();
</script>
<script type="text/javascript">
$(document).ready(function() {
$('.mdb-select').material_select();
});
</script>

如果这段代码位于我发布的代码的底部,那么levo会让我提取所有内容:

<script src="../../js/pagination.js"></script>

如果相反,我则拒绝。我不明白。我还把提取所有内容的部分放到xls中:

<?php
include '../../connessione.php';
?>
<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset="utf-8">
        <title>Contato</title>
    <head>
    <body>
        <?php
        if(isset($_POST['estrai'])){
            // Definimos o nome do arquivo que será exportado
            $arquivo = 'excel_clienti_selezionati.xls';

            // Criamos uma tabela HTML com o formato da planilha
            $html = '';
            $html .= '<table border="0">';
            $html .= '<tr>';
            $html .= '<td><b>Nome</b></td>';
            $html .= '<td><b>Cognome</b></td>';
            $html .= '<td><b>Email</b></td>';
            $html .= '<td><b>Telefono</b></td>';

            $html .= '</tr>';



            foreach($_POST['estrai'] as $cliente_id => $estrai){
                //echo "cliente_id do item: $cliente_id <br>";
                //Selecionar todos os itens da tabela 
                $result_msg_contatos = "SELECT * FROM clienti WHERE cliente_id = $cliente_id";
                $resultado_msg_contatos = mysqli_query($connessione , $result_msg_contatos);

                while($row = mysqli_fetch_assoc($resultado_msg_contatos)){
                    $html .= '<tr>';
                    $html .= '<td>'.$row["nome"].'</td>';
                    $html .= '<td>'.$row["cognome"].'</td>';
                    $html .= '<td>'.$row["email"].'</td>';
                    $html .= '<td>'.$row["telefono"].'</td>';
                    $html .= '</tr>';
                    ;
                }
            }
            // Configurações header para forçar o download
            header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
            header ("Cache-Control: no-cache, must-revalidate");
            header ("Pragma: no-cache");
            header ("Content-type: application/x-msexcel");
            header ("Content-Disposition: attachment; filename=\"{$arquivo}\"" );
            header ("Content-Description: PHP Generated Data" );
            // Envia o conteúdo do arquivo
            echo $html;
            exit;
        }else{
            echo "Nessun ";
        }

        ?>

为什么?我需要该文件js,因为它可以调整表格的搜索栏和分页,但是我需要在xls中提取

0 个答案:

没有答案