คือเราต้องการส่งค่า id จากหน้าตารางที่แสดงข้อมูลในdatabase เพื่อไปดาวน์โหลดไฟล์ที่อยู่ในdatabaseค่ะ
โดยการคลิ้กจากa href
นี้โค้ดเต็มค่ะ ฝากผู้รู้ช่วยหน่อนนะคะ
<!DOCTYPE html>
<?php
include 'config.php';
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kembangan International</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/searchp.css">
<style>
.loading{
background-image: url("ajax-loader.gif");
background-repeat: no-repeat;
display: none;
height: 100px;
width: 100px;
}
</style>
</head>
<body>
<section>
<h1>Sub Contractor & Sub Labour <br> Database Information</h1>
<div class="container">
<div class="row">
<div class="col-md-12">
<form class="form-inline" name="searchform" id="searchform">
<div class="form-group" style="padding-right:5px;">
<input type="text" name="itemname" id="itemname" class="form-control" placeholder="Masukkan Nama" autocomplete="off">
</div>
<button type="button" class="btn btn-primary" id="btnSearch">
<span class="glyphicon glyphicon-search"></span>
Cari
</button>
</form>
<form class="form-inline" method="post" action="generate_excel.php" style="padding-top:5px;">
<button type="submit" name="export_excel" value="Export" class="btn btn-primary">
<i class="fa fa-pdf" aria-hidden="true"></i>Download EXCEL
</button>
</form>
</div>
</div>
<div class="loading"></div>
<section class="row" id="list-data" style="margin-top: 5px;width:108%">
<div class="tbl-header">
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th style="width:2%" >No.</th>
<th>Nama</th>
<th>No Tel.</th>
<th>Nama Syarikat</th>
<th>No. Pendaftaran Syarikat </th>
<th>Lokasi</th>
<th>Skop Kerja</th>
<th style="width:15%">Nota</th>
<th>Kemahiran</th>
<th>Document</th>
<th>Download Document</th>
<th>Download PDF</th>
</tr>
</thead>
</table>
</div>
<div class="tbl-content">
<div class="loading"></div>
<table cellpadding="0" cellspacing="0" border="0" id="list-data">
<tbody>
<?php
require_once "config.php";
$bil=1;
$stu = mysqli_query($link,"select * from information");
while($row = mysqli_fetch_array($stu))
{
?>
<tr>
<th style="width:2%"><?php echo $bil;?></th>
<td><?php echo $row['name'];?></td>
<td><?php echo $row['notel'];?></td>
<td><?php echo $row['nmasyarikat'];?></td>
<td><?php echo $row['nopendsya'];?></td>
<td><?php echo $row['lokasi'];?></td>
<td><?php echo $row['skop'];?></td>
<td style="width:15%;word-wrap:break-word"><?php echo $row['pekerja'];?></td>
<td><?php echo $row['kemahiran'];?></td>
<td style="word-wrap:break-word"><?php echo $row['document'];?></td>
<td><a href="download.php?FileNo=<?echo $row['id'];?>" style="color:white" method="post">Download</a></td> <-- ต้องการคลิ้กดาวน์โหลดจากตรงนี้
<td><a ></a></td>
<td><a href="generate-user-pdf.php" style="color:white">PDF Download</a></td>
</tr>
<?php
$bil++;
}
?>
</tbody>
</table>
</div>
</section>
</div>
</section>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btnSearch").click(function () {
$.ajax({
url: "searchdis.php",
type: "post",
data: {itemname: $("#itemname").val()},
beforeSend: function () {
$(".loading").show();
},
complete: function () {
$(".loading").hide();
},
success: function (data) {
$("#list-data").html(data);
}
});
});
$("#searchform").on("keyup keypress",function(e){
var code = e.keycode || e.which;
if(code==13){
$("#btnSearch").click();
return false;
}
});
});
</script>
</body>
</html>
ส่งค่าผ่าน a href ทำยังไงหรอคะ
โดยการคลิ้กจากa href
นี้โค้ดเต็มค่ะ ฝากผู้รู้ช่วยหน่อนนะคะ
<!DOCTYPE html>
<?php
include 'config.php';
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kembangan International</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/searchp.css">
<style>
.loading{
background-image: url("ajax-loader.gif");
background-repeat: no-repeat;
display: none;
height: 100px;
width: 100px;
}
</style>
</head>
<body>
<section>
<h1>Sub Contractor & Sub Labour <br> Database Information</h1>
<div class="container">
<div class="row">
<div class="col-md-12">
<form class="form-inline" name="searchform" id="searchform">
<div class="form-group" style="padding-right:5px;">
<input type="text" name="itemname" id="itemname" class="form-control" placeholder="Masukkan Nama" autocomplete="off">
</div>
<button type="button" class="btn btn-primary" id="btnSearch">
<span class="glyphicon glyphicon-search"></span>
Cari
</button>
</form>
<form class="form-inline" method="post" action="generate_excel.php" style="padding-top:5px;">
<button type="submit" name="export_excel" value="Export" class="btn btn-primary">
<i class="fa fa-pdf" aria-hidden="true"></i>Download EXCEL
</button>
</form>
</div>
</div>
<div class="loading"></div>
<section class="row" id="list-data" style="margin-top: 5px;width:108%">
<div class="tbl-header">
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th style="width:2%" >No.</th>
<th>Nama</th>
<th>No Tel.</th>
<th>Nama Syarikat</th>
<th>No. Pendaftaran Syarikat </th>
<th>Lokasi</th>
<th>Skop Kerja</th>
<th style="width:15%">Nota</th>
<th>Kemahiran</th>
<th>Document</th>
<th>Download Document</th>
<th>Download PDF</th>
</tr>
</thead>
</table>
</div>
<div class="tbl-content">
<div class="loading"></div>
<table cellpadding="0" cellspacing="0" border="0" id="list-data">
<tbody>
<?php
require_once "config.php";
$bil=1;
$stu = mysqli_query($link,"select * from information");
while($row = mysqli_fetch_array($stu))
{
?>
<tr>
<th style="width:2%"><?php echo $bil;?></th>
<td><?php echo $row['name'];?></td>
<td><?php echo $row['notel'];?></td>
<td><?php echo $row['nmasyarikat'];?></td>
<td><?php echo $row['nopendsya'];?></td>
<td><?php echo $row['lokasi'];?></td>
<td><?php echo $row['skop'];?></td>
<td style="width:15%;word-wrap:break-word"><?php echo $row['pekerja'];?></td>
<td><?php echo $row['kemahiran'];?></td>
<td style="word-wrap:break-word"><?php echo $row['document'];?></td>
<td><a href="download.php?FileNo=<?echo $row['id'];?>" style="color:white" method="post">Download</a></td> <-- ต้องการคลิ้กดาวน์โหลดจากตรงนี้
<td><a ></a></td>
<td><a href="generate-user-pdf.php" style="color:white">PDF Download</a></td>
</tr>
<?php
$bil++;
}
?>
</tbody>
</table>
</div>
</section>
</div>
</section>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btnSearch").click(function () {
$.ajax({
url: "searchdis.php",
type: "post",
data: {itemname: $("#itemname").val()},
beforeSend: function () {
$(".loading").show();
},
complete: function () {
$(".loading").hide();
},
success: function (data) {
$("#list-data").html(data);
}
});
});
$("#searchform").on("keyup keypress",function(e){
var code = e.keycode || e.which;
if(code==13){
$("#btnSearch").click();
return false;
}
});
});
</script>
</body>
</html>