javascript - 无需 js 即可删除 js 文件和表单 - Javascript / Jquery
问题描述
那么我不明白为什么,这段代码显示了一个包含在表格中的表格,该表格通过复选框和按下特定的 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 中提取
解决方案
推荐阅读
- java - 为什么在代码中使用正则表达式模式 [1-3]\\s+[1-3] 不匹配用空格分隔的两个数字
- javascript - TypeError 无法读取 null 的属性“country_code”
- c - 如何制作动态字符串?
- android - 无法获取根集合下的所有文档 - Firestore Android
- java - arrayList.remove 方法在 java 中不起作用
- wpf - 如何像wpf中的标准对话框一样设置自定义对话框的自动开始定位?
- javascript - 如何通过加载保存的搜索功能处理填充下拉列表
- javascript - Accelerated Mobile Pages (AMP) - External script
- javascript - How to load external .js to the body of a Wordpress Page?
- php - Redirect URLs ending with .php to new URL in Laravel & Nginx