คือผมอยากจะทำปุ่มสำหรับไว้กด export ข้อมูลจากฐานข้อมูลออกมาเป็น excel ซึ่งในตอนแรกผมก็ลองดูแล้วแต่กลายเป็นว่าใส่เข้าไปแล้วไม่เห็นปุ่มขึ้น ผมเลยงงว่ามันผิดตรงไหน ใครทราบช่วยบอกทีครับ ขอบคุณมากครับ
<?php session_start(); ?>
<?php if(empty($_SESSION['user_id'])){echo "<meta http-equiv='refresh' content='0;url=index.php'/>";exit();} ?>
<?php include 'header.php';?>
<?php
$user_id = $_SESSION[user_id];
$sqlUser = mysql_query("select admin from user where user_id='$user_id' ");
$resultUser=mysql_fetch_assoc($sqlUser);
if($resultUser[admin]=='Y'){
echo "<h2>คณะกรรมการบริหารความเสี่ยง</h2>";
}else{
echo "<h2>รายงานสำหรับหน่วยงาน</h2>";
}
?>
<ol class="breadcrumb">
<li><a href="index.php"><i class="fa fa-home"></i> หน้าหลัก</a></li>
<?php if($resultUser[admin]=='Y'){ echo "<li><a href='main_department_report.php'><i class='fa fa-bar-chart-o'></i> หน่วยงานที่เขียนความเสี่ยง</a></li>"; } ?>
<li class="active"><i class="fa fa-user"></i> บุคลากรที่เขียนความเสี่ยง</li>
</ol>
<H1><small>รายชื่อบุคลากรภายในหน่วยงานที่เขียนความเสี่ยง</small></H1>
<div class="col-lg-7">
<form method="post" action="" enctype="multipart/form-data" >
***เลือกวันที่เริ่มต้นและวันที่สิ้นสุดเพื่อดูจำนวนความเสี่ยง
<div class="form-group">
วันที่เริ่มต้น <input type='date' id='date_start' name='date_start' class='form-control' required />
</div>
<div class="form-group">
วันที่สิ้นสุด <input type='date' name='date_end' class='form-control' required />
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">ตกลง</button>
</div>
</form>
</div>
<div class="col-lg-7">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-calendar"></i> รายชื่อบุคลากรภายในหน่วยงานที่เขียนความเสี่ยง</h3>
</div>
<div class="panel-body">
<div class="table-responsive">
<table id="datatable" class="table table-bordered table-hover table-striped tablesorter">
<thead>
<tr>
<th><center>ลำดับ <i class="fa fa-sort"></i></center></th>
<th><center>รายชื่อ <i class="fa fa-sort"></i></center></th>
<th><center>จำนวนเรื่อง <i class="fa fa-sort"></i></center></th>
</tr>
</thead>
<tbody>
<?php
$i=1;
$monthlast =$_POST[date_start];
$monthnow =$_POST[date_end];
if($_POST[dep_id]!=''){
$dep_ids=$_POST[dep_id];
}else{
$dep_ids=$_SESSION[user_dep_id];
}
$sql=mysql_query("select * from user where dep_id='$dep_ids'");
while( $result=mysql_fetch_assoc($sql) ){
$RSuser_id=$result[user_id];
$sql2=mysql_query("select t1.takerisk_id
from takerisk t1
where t1.take_rec_date between '$monthlast' and '$monthnow' and t1.user_id='$RSuser_id'
and t1.recycle='N'");
$count_risk=mysql_num_rows($sql2);
echo mysql_error();
$rs=mysql_fetch_assoc($sql2) ;
?>
<tr>
<td><center><?php echo $i; ?></center></td>
<td><?php echo $result[user_fname].' '.$result[user_lname]; ?></td>
<td><center><?php if($count_risk==0){echo "<font color='red'>".$count_risk."</font>"; }else{echo $count_risk;} ?></center></td>
</tr>
<tr>
<?php $i++; } // end while $sql2 ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div><!-- /.row -->
<?php include 'footer.php';?>
</section>
ทำปุ่ม export จากฐานข้อมูลเป็น excel ยังไงครับ
Moderator: mindphp, ผู้ดูแลกระดาน
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41378
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: ทำปุ่ม export จากฐานข้อมูลเป็น excel ยังไงครับ
ลองดูตามบทความนี้ครับ
https://www.mindphp.com/developer/26-%E0 ... A-csv.html
https://www.mindphp.com/developer/26-%E0 ... A-csv.html
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
Re: ทำปุ่ม export จากฐานข้อมูลเป็น excel ยังไงครับ
ผมมือใหม่ในการเขียนโค้ดมากครับ แบบว่าโค้ดตัวนี้เพื่อนผมส่งมาให้ แต่มันไม่ได้เขียนปุ่มกด export แบบไฟล์ excel ได้ให้ แถมจะไปกวนมันมากก็ไม่ได้เพราะเพื่อนผมเองก็มีงานทำประจำของเขาเองเหมือนกัน ที่ยอมทำให้แล้วส่งมาขนาดนี้ก็บุญแล้วล่ะครับ รบกวนช่วยบอกตรงที่ต้องใส่โค้ดกับแก้ตรงส่วนไหนเพิ่มเติมบ้างก็ได้ครับ
-
- PHP Newbie
- โพสต์: 1
- ลงทะเบียนเมื่อ: 21/03/2017 1:36 pm
Re: ทำปุ่ม export จากฐานข้อมูลเป็น excel ยังไงครับ
แบบว่าผมไปขอให้เพื่อนเขียนอันนี้มา เลยไม่ค่อยเข้าใจครับ ช่วยบอกเพิ่มหน่อยได้มั้ยครับว่าต้องแก้เพิ่มเติมตรงไหนบ้างจากโค้ดเดิมของผมที่โพสไว้เมื่อกี้น่ะ
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
-
โพสต์ใหม่ รบกวนช่วยหน่อยครับมือใหม่ export excel
โดย Chai8 » 19/09/2016 3:40 pm » ใน Programming - PHP - 1 ตอบกลับ
- 1594 แสดง
-
โพสต์ล่าสุด โดย mindphp
21/03/2017 2:54 pm
-
-
-
โพสต์ใหม่ สอบถามการทำ export เป็นไฟล์ excel
โดย Thanapoom1514 » 04/10/2023 11:15 am » ใน Joomla Development - 2 ตอบกลับ
- 1369 แสดง
-
โพสต์ล่าสุด โดย Deepaverma
05/10/2023 1:48 pm
-
-
-
โพสต์ใหม่ สอบถามเกี่ยวกับวิธีแก้ไข การ export excel ครับ
โดย flook » 25/07/2023 10:53 pm » ใน JavaScript & jQuery Ajax & Node.JS - 1 ตอบกลับ
- 1501 แสดง
-
โพสต์ล่าสุด โดย mindphp
26/07/2023 12:24 pm
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: Google Adsense [Bot] และบุคลทั่วไป 134