When click on checkbox it show multiple value? - php

view:
<script>
$(document).ready(function(){
$(".uid").click(function(){
jid = $(".jid").attr("id");
uid = $(':checked').map(function() {
return this.id;
}).get().join(',');
$.ajax({
type:"POST",
data:{"jid":jid, "uid":uid},
url:"<?php echo base_url(); ?>shortlist",
success:function(data){
$(".stage_shortlist").html(data);
}
});
});
$(document).on("click",".uid_short",function(){
jid_short = $(".jid_short").attr("id");
uid_short = $(':checked').map(function() {
return this.id;
}).get().join(',');
alert(jid_short);
alert(uid_short);
});
});
</script>
<h2>Received</h2>
<section>
<table class="table table-hover js-basic-example dataTable table-custom m-b-0">
<thead>
<tr>
<th>Name</th>
<th>Shortlist</th>
</tr>
</thead>
<tbody>
<?php
$this->db->select('*');
$this->db->from('upload_detail');
$where = "jid='".$row['job_id']."' and share_with_emp='1'";
$this->db->where($where);
$sql = $this->db->get();
if($sql->num_rows() > 0)
{
$result = $sql->result_array();
foreach($result as $recieve)
{
?>
<tr>
<td><?php echo $recieve['fname']; ?></td>
<td>
<div class="fancy-checkbox">
<label>
<input type="hidden" name="jid" class="jid" id="<?php echo $recieve['jid']; ?>"/>
<?php
if($recieve['shortlist']=='1')
{
echo '<input type="checkbox" name="uid" id="" class="uid" checked disabled><span>Shortlist</span>';
}
else
{
echo '<input type="checkbox" name="uid" id="'.$recieve["uid"].'" class="uid"><span>Shortlist</span>';
}
?>
</label>
</div>
</td>
</tr>
<?php
}
}
else
{
echo "<p>No resume Found</p>";
}
?>
</tbody>
</table>
</section>
<h2>Shortlisted</h2>
<section>
<table class="table table-hover js-basic-example dataTable table-custom m-b-0">
<thead>
<tr>
<th>Name</th>
<th>Shortlist</th>
</tr>
</thead>
<tbody class="stage_shortlist">
<?php
$this->db->select('*');
$this->db->from('upload_detail');
$where = "jid='".$row['job_id']."' and shortlist='1'";
$this->db->where($where);
$sql_short = $this->db->get();
$result_short = $sql_short->result_array();
foreach($result_short as $short)
{
?>
<tr>
<td><?php echo $short['fname']; ?></td>
<td>
<div class="fancy-checkbox">
<label>
<input type="hidden" name="jid_short" class="jid_short" id="<?php echo $short['jid']; ?>"/>
<?php
if($short['interview']=='1')
{
echo '<input type="checkbox" name="uid_short" id="" class="uid_short" checked disabled><span>Shortlist</span>';
}
else
{
echo '<input type="checkbox" name="uid_short" id="'.$short["uid"].'" class="uid_short"><span>Shortlist</span>';
}
?>
</label>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</section>
controller:
<?php
public function shortlist()
{
$jid = $this->input->post('jid');
$uid = explode(",",$this->input->post('uid'));
$data = array('shortlist'=>'1');
foreach($uid as $user_id)
{
$where = "uid='".$user_id."' and jid='".$jid."'";
$this->db->where($where);
$sql = $this->db->update('upload_detail',$data);
}
if($sql==true)
{
$this->db->select('*');
$this->db->from('upload_detail');
$where = "jid='".$jid."' and shortlist='1'";
$this->db->where($where);
$sql_short = $this->db->get();
$result_short = $sql_short->result_array();
foreach($result_short as $short)
{
?>
<tr>
<td><?php echo $short['fname']; ?></td>
<td>
<div class="fancy-checkbox">
<label>
<input type="hidden" name="jid_short" class="jid_short" id="<?php echo $short['jid']; ?>"/>
<?php
if($short['interview']=='1')
{
echo '<input type="checkbox" name="uid_short" id="" class="uid_short" checked disabled><span>Shortlist</span>';
}
else
{
echo '<input type="checkbox" name="uid_short" id="'.$short["uid"].'" class="uid_short"><span>Shortlist</span>';
}
?>
</label>
</div>
</td>
</tr>
<?php
}
}
else
{
echo '<p>Unable to proceed!</p>';
}
}
?>
In this code I am update shortlist value 1 onclick uid which is the part of recieved heading section and response call from shortlist controller which is work perfectly but problem is that when I click on class uid_short it alert multiple value inside the alert(uid_short); I don't know what where am I doing wrong? Please help me to solve this issue.
Thank You

Related

Can't redirect after update data codeigniter and still in current page

Help, i cant redirect after update data, after edit the page still in current page. but when i place the redirect function after query $update, when i press edit button the page will go to redirect page and data edit form not show. How to fix this?
My Controller
is it i make a wrong if?
public function edit_anggaran($getId)
{
$id = encode_php_tags($getId);
$data_id = $this->uri->segment('4');
$this->_validasi();
if ($this->form_validation->run() == false) {
$data['title'] = "Detail Anggaran Pengajuan Proposal";
$data['detail_anggaran_proposal'] = $this->admin->get('detail_anggaran_proposal', ['id_detail_anggaran_proposal' => $data_id]);
$data['proposal'] = $this->admin->get('proposal', ['id_proposal' => $id]);
if ($this->template->load('templates/dashboard', 'proposal/edit_anggaran', $data)){
$d = array( 'nama_kebutuhan'=> $this->input->post('nama_kebutuhan'),
'harga' => $this->input->post('harga'),
'jumlah'=> $this->input->post('jumlah')
);
}
$update = $this->admin->update_detail('detail_anggaran_proposal', 'id_detail_anggaran_proposal', $data_id, $d);
redirect('proposal/anggaran/'.$id);
} else {
if ($update) {
set_pesan('data berhasil disimpan.');
redirect('proposal/anggaran/'.$id);
} else {
set_pesan('data gagal disimpan', false);
redirect('proposal/add');
}
// $input = $this->input->post(null, true);
}
}
My Model
public function update_detail($table, $pk, $id, $data)
{
$this->db->where($pk, $id);
return $this->db->update($table, $data);
}
My View
<div class="card-body">
<?= $this->session->flashdata('pesan'); ?>
<?= form_open('', [], ['id_detail_anggaran_proposal' => $detail_anggaran_proposal['id_detail_anggaran_proposal']]); ?>
<table class="table table-bordered" id="">
<thead>
<tr>
<th>Nama Kebutuhan</th>
<th>Harga</th>
<th>Jumlah</th>
<th>Total Harga</th>
</tr>
</thead>
<tbody>
<td><input value="<?= set_value('nama_kebutuhan', $detail_anggaran_proposal['nama_kebutuhan']); ?>" name="nama_kebutuhan" id="nama_kebutuhan" type="text" class="form-control" ></td>
<td><input value="<?= set_value('harga', number_format($detail_anggaran_proposal['harga'],'0',',','.')); ?>" name="harga" id="harga" type="text" class="form-control" ></td>
<td><input value="<?= set_value('jumlah', $detail_anggaran_proposal['jumlah']); ?>" name="jumlah" id="jumlah" type="text" class="form-control" ></td>
<?php $total=0; ?>
<td>Rp. <?= number_format($subtotal=$detail_anggaran_proposal['harga'] * $detail_anggaran_proposal['jumlah'],'0',',','.'); $total += $subtotal; ?> </td>
</tr>
<tr>
<td colspan="3" class="text-center"><h5><b>Total Anggaran </b></h5></td>
<td>Rp. <?= number_format($total,'0',',','.') ?></td>
</tr>
</tbody>
</table>
<div class="row form-group">
<div class="col-md-9 offset-md-3">
<button type="submit" class="btn btn-primary" style="float: right;">Simpan</button>
</div>
</div>
</div>
</div>
<?= form_close(); ?>
</div>

Value inserting on last row

Shown in the image above, I have two entries on my stock_transfer table.
As an example, I will insert two different values to show you that it's working. (5 stocks on Product 1 and 10 stocks on Product 2)
Now, when I try to insert the stocks requested remaining on Product 1 and leave the Product 2, it will be successful.
Here comes the problem. When I try to insert value (290 stocks) on my Product 2, it will insert the value in the Product 1 table.
Can anyone help me with this? Here's my query code:
if (isset($_POST['addCart']) && $_POST['addCart']=="Confirm Stock Transfer") {
foreach($_POST['qtyBuy'] as $index=>$value){
if($value > 0){
$cartProd_id = $_POST['product_id'][$index];
$cartProd_name = $_POST['product_name'][$index];
$cartProd_date = $_POST['product_exp'][$index];
$cartProd_desc = $_POST['product_desc'][$index];
$cartProd_transid = $_POST['transfer_id'][$index];
//Update stock_transfer requests
$update_stock = "UPDATE stock_transfer SET stocks_transferred = stocks_transferred + $value WHERE transfer_id = $cartProd_transid;";
$update_stockE = mysqli_query($connection, $update_stock);
Here's is my code:
<table class="table table-striped table-bordered table-hover results table-fixed table-condensed" id="example">
<thead>
<tr>
<th>#</th>
<th>Product Name</th>
<th>Description</th>
<th>Sell Price</th>
<th>Expiry Date</th>
<th>Instock</th>
<th>Stocks Requested Remaining</th>
<th>Stocks Transferred</th>
<th>Quantity to Transfer</th>
</tr>
</thead>
<tbody>
<?php
$getReq = "SELECT * FROM stock_transfer INNER JOIN td_products ON stock_transfer.transfer_product_id = td_products.product_id WHERE stock_transfer.transfer_number = $tid AND stock_transfer.transfer_tobranch = '$capitalPrefix';";
$getReqE = mysqli_query($connection, $getReq);
while ($row = mysqli_fetch_array($getReqE)) {
$transfer_id = $row['transfer_id'];
$transfer_number = $row['transfer_number'];
$transfer_status = $row['transfer_status'];
$transfer_frombranch = $row['transfer_frombranch'];
$transfer_tobranch = $row['transfer_tobranch'];
$transfer_product_id = $row['transfer_product_id'];
$transfer_quantity = $row['transfer_quantity'];
$transfer_date = $row['transfer_date'];
$stocks_transferred = $row['stocks_transferred'];
$remainingStocks = $transfer_quantity - $stocks_transferred;
$product_id = $row['product_id'];
$product_name = $row['product_name'];
$product_price = $row['sell_price'];
$description = $row['description'];
$quantity = $row['quantity'];
$expiry_date = $row['expiry_date'];
echo $transfer_id;
?>
<tr>
<td class="text-center"><?php echo $product_id; ?>
<input type="hidden" name="product_id[]" value="<?php echo $product_id; ?>">
</td>
<input type="hidden" name="transfer_id[]" value="<?php echo $transfer_id; ?>">
<td><?php echo $product_name; ?>
<input type="hidden" name="product_name[]" value="<?php echo $product_name; ?>">
</td>
<td><?php echo $description; ?>
<input type="hidden" name="product_desc[]" value="<?php echo $description; ?>">
</td>
<td>₱ <?php echo number_format($product_price, 2); ?></td>
<td><?php echo $expiry_date; ?>
<input type="hidden" name="product_exp[]" value="<?php echo $expiry_date; ?>">
</td>
<td><strong><?php echo $quantity; ?></strong></td>
<td><?php echo $remainingStocks; ?></td>
<td><?php echo $stocks_transferred; ?></td>
<td>
<?php if (!$remainingStocks == 0){ ?>
<input type="number" name="qtyBuy[]" id="<?php echo "qtyBuy" . $b++; ?>" min="1" max="<?php echo $remainingStocks;?>">
<?php } else{ ?>
<i class="glyphicon glyphicon-check"></i> Completed
<?php } ?>
</td>
</tr>
<?php }?>
</tbody>
</table>
<div class="form-group">
<input type="submit" name="addCart" value="Confirm Stock Transfer" class="btn btn-info pull-right">
Back to Request List
</div>
Tags
Here's my schema:
See this:
<td>
<input type="number" name="qtyBuy[]" id="<?php echo "qtyBuy" . $b++; ?>" min="1" max="<?php echo $remainingStocks;?>" <?php echo ($remainingStocks == 0') ? 'Disabled=true' : '';?> value="0">
</td>
for security issues, I advise you to use ajax and submit just the qty input for one row each time:
<table class="table table-striped table-bordered table-hover results table-fixed table-condensed" id="example">
<thead>
<tr>
<th>#</th>
<th>Product Name</th>
<th>Description</th>
<th>Sell Price</th>
<th>Expiry Date</th>
<th>Instock</th>
<th>Stocks Requested Remaining</th>
<th>Stocks Transferred</th>
<th>Quantity to Transfer</th>
</tr>
</thead>
<tbody>
<?php
$getReq = "SELECT * FROM stock_transfer INNER JOIN td_products ON stock_transfer.transfer_product_id = td_products.product_id WHERE stock_transfer.transfer_number = $tid AND stock_transfer.transfer_tobranch = '$capitalPrefix';";
$getReqE = mysqli_query($connection, $getReq);
while ($row = mysqli_fetch_array($getReqE)) {
$transfer_id = $row['transfer_id'];
$transfer_number = $row['transfer_number'];
$transfer_status = $row['transfer_status'];
$transfer_frombranch = $row['transfer_frombranch'];
$transfer_tobranch = $row['transfer_tobranch'];
$transfer_product_id = $row['transfer_product_id'];
$transfer_quantity = $row['transfer_quantity'];
$transfer_date = $row['transfer_date'];
$stocks_transferred = $row['stocks_transferred'];
$remainingStocks = $transfer_quantity - $stocks_transferred;
$product_id = $row['product_id'];
$product_name = $row['product_name'];
$product_price = $row['sell_price'];
$description = $row['description'];
$quantity = $row['quantity'];
$expiry_date = $row['expiry_date'];
echo $transfer_id;
?>
<tr>
<td class="text-center"><?php echo $product_id; ?>
</td>
<td><?php echo $product_name; ?>
</td>
<td><?php echo $description; ?>
</td>
<td>₱ <?php echo number_format($product_price, 2); ?></td>
<td><?php echo $expiry_date; ?>
</td>
<td><strong><?php echo $quantity; ?></strong></td>
<td><?php echo $remainingStocks; ?></td>
<td><?php echo $stocks_transferred; ?></td>
<td>
<?php if (!$remainingStocks == 0){ ?>
<input type="number" name="qtyBuy[]" id="qty_buy_<?= $transfer_id ?>" min="1" max="<?php echo $remainingStocks;?>"><a class="btn btn-sm add_qty" data-id="<?= $transfer_id ?>"></a>
<?php } else{ ?>
<i class="glyphicon glyphicon-check"></i> Completed
<?php } ?>
</td>
</tr>
<?php }?>
</tbody>
</table>
<div class="form-group">
<input type="submit" name="addCart" value="Confirm Stock Transfer" class="btn btn-info pull-right">
Back to Request List
</div>
<script>
$(function() {
$('.add_qty').click(function() {
var id = $(this).data('id');
var qty = $("#qty_buy_"+id).val();
$.ajax({
type: 'GET',
url:'/your_action',
data: {id : id, qty : qty},
dataType: 'JSON',
}).done(function(json){
// code to update the values in your row
});
});
});
</script>
The problem was on the
<?php if (!$remainingStocks == 0){ ?>
<input type="number" name="qtyBuy[]" id="<?php echo "qtyBuy" . $b++; ?>" min="1" max="<?php echo $remainingStocks;?>">
<?php } else{ ?>
<i class="glyphicon glyphicon-check"></i> Completed
<?php } ?>
I think the problem is with your input names. You have assigned arrays as names of your inputs. Try to make them unique using the product id.

PHP PDO CRUD display data based on select box value

i was doing practice of PHP PDO CRUD example of codingcage ...link is http://www.codingcage.com/2015/04/php-pdo-crud-tutorial-using-oop-with.html
-- in index.php i have created a select box with dynamic value :
$conn = new mysqli('localhost', 'root', '', 'kk') or die ('Cannot connect to db');
$result = $conn->query("SELECT DISTINCT project FROM tbl_activitymaster where ProjectFlag='open' ");
echo "<html>";
echo "<body>";
echo "<select name='unqprj'>";
while ($row = $result->fetch_assoc()) {
unset($project, $project);
$project = $row['project'];
$name = $row['project'];
echo '<option value="'.$project.'">'.$project.'</option>';
$value="<?php echo $project;?>";
}
echo "</select>";
echo "</body>";
echo "</html>";
But the problem is that how to use this select box in the crud example to filter the records based on the value selected . I have done it in asp.net but in php how to do this. any help please or any link
// as mulder is suggesting but no idea how to implement with this eaample
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' name='form2' >
<select name="value">
<option value="all">All</option>
<option value="Project1">Project1</option>
<option value="Project2">Project2</option>
</select>
<input type='submit' value = 'Show'>
</form>
class.crud.php..............
//show
public function dataview($query)
{
$stmt = $this->db->prepare($query);
$stmt->execute();
if($stmt->rowCount()>0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<td><?php print($row['id']); ?></td>
<td><?php print($row['Project']);?></td>
<td><?php print($row['ProjectUser']);?></td>
<td><?php print($row['Month']);?></td>
<td><?php print($row['Status']);?></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td>Nothing here...</td>
</tr>
<?php
}
}
//paging
public function paging($query,$records_per_page)
{
$starting_position=0;
if(isset($_GET["page_no"]))
{
$starting_position=($_GET["page_no"]-1)*$records_per_page;
}
$query2=$query." limit $starting_position,$records_per_page";
return $query2;
}
index.php...............
<?php include_once '../header.php'; ?>
<?php include_once 'dbconfig.php'; ?>
<?php
$conn = new mysqli('localhost', 'root', '', 'kk')
or die ('Cannot connect to db');
$result = $conn->query("SELECT DISTINCT project FROM tbl_activitymaster where ProjectFlag='open' ");
echo "<html>";
echo "<body>";
echo "<select name='unqprj'>";
while ($row = $result->fetch_assoc()) {
unset($project, $project);
$project = $row['project'];
$name = $row['project'];
echo '<option value="'.$project.'">'.$project.'</option>';
$value="<?php echo $project;?>";
echo "</select>";
echo "</body>";
echo "</html>";
?>
<div class="container">
<table class='table table-bordered table-hover table-responsive'>
<thead style="background-color:#FFFBF0">
<tr>
<th>ID</th>
<th>Project</th>
<th>ProjectUser</th>
<th>Month</th>
<th>Status</th>
</tr>
</thead>
<?php
$query = "SELECT * FROM tbl_activitymaster where ProjectUser='" . ($_SESSION['sess_username']) . "' ";
$records_per_page=10;
$newquery = $crud->paging($query,$records_per_page);
$crud->dataview($newquery);
?>
<tr>
<td colspan="7" align="center">
<div class="pagination-wrap">
<?php $crud->paginglink($query,$records_per_page); ?>
</div>
</td>
</tr>
</table>
</div>
<?php include_once '../footer.php'; ?>
Here the code of codeingcage firstly and you need to just inject select box over there like:
Index.php
<?php
include_once 'dbconfig.php';
?>
<?php include_once 'header.php'; ?>
<div class="clearfix"></div>
<div class="container">
<i class="glyphicon glyphicon-plus"></i> Add Records
</div>
<div class="clearfix"></div><br />
<div class="container">
<table class='table table-bordered table-responsive'>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>E - mail ID</th>
<th>Contact No</th>
<th colspan="2" align="center">Actions</th>
</tr>
<?php
$query = "SELECT * FROM tbl_users";
$records_per_page=3;
$newquery = $crud->paging($query,$records_per_page);
$crud->dataview($newquery);
?>
<tr>
<td colspan="7" align="center">
<div class="pagination-wrap">
<?php $crud->paginglink($query,$records_per_page); ?>
</div>
</td>
</tr>
</table>
</div>
<?php include_once 'footer.php'; ?>
dbconfig.php
<?php
$DB_host = "localhost";
$DB_user = "root";
$DB_pass = "";
$DB_name = "dbpdo";
try
{
$DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo $e->getMessage();
}
include_once 'class.crud.php';
$crud = new crud($DB_con);
?>
class.crud.php
<?php
class crud
{
private $db;
function __construct($DB_con)
{
$this->db = $DB_con;
}
public function create($fname,$lname,$email,$contact)
{
try
{
$stmt = $this->db->prepare("INSERT INTO tbl_users(first_name,last_name,email_id,contact_no) VALUES(:fname, :lname, :email, :contact)");
$stmt->bindparam(":fname",$fname);
$stmt->bindparam(":lname",$lname);
$stmt->bindparam(":email",$email);
$stmt->bindparam(":contact",$contact);
$stmt->execute();
return true;
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}
public function getID($id)
{
$stmt = $this->db->prepare("SELECT * FROM tbl_users WHERE id=:id");
$stmt->execute(array(":id"=>$id));
$editRow=$stmt->fetch(PDO::FETCH_ASSOC);
return $editRow;
}
public function update($id,$fname,$lname,$email,$contact)
{
try
{
$stmt=$this->db->prepare("UPDATE tbl_users SET first_name=:fname,
last_name=:lname,
email_id=:email,
contact_no=:contact
WHERE id=:id ");
$stmt->bindparam(":fname",$fname);
$stmt->bindparam(":lname",$lname);
$stmt->bindparam(":email",$email);
$stmt->bindparam(":contact",$contact);
$stmt->bindparam(":id",$id);
$stmt->execute();
return true;
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}
public function delete($id)
{
$stmt = $this->db->prepare("DELETE FROM tbl_users WHERE id=:id");
$stmt->bindparam(":id",$id);
$stmt->execute();
return true;
}
/* paging */
public function dataview($query)
{
$stmt = $this->db->prepare($query);
$stmt->execute();
if($stmt->rowCount()>0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<tr>
<td><?php print($row['id']); ?></td>
<td><?php print($row['first_name']); ?></td>
<td><?php print($row['last_name']); ?></td>
<td><?php print($row['email_id']); ?></td>
<td><?php print($row['contact_no']); ?></td>
<td align="center">
<i class="glyphicon glyphicon-edit"></i>
</td>
<td align="center">
<i class="glyphicon glyphicon-remove-circle"></i>
</td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td>Nothing here...</td>
</tr>
<?php
}
}
public function paging($query,$records_per_page)
{
$starting_position=0;
if(isset($_GET["page_no"]))
{
$starting_position=($_GET["page_no"]-1)*$records_per_page;
}
$query2=$query." limit $starting_position,$records_per_page";
return $query2;
}
public function paginglink($query,$records_per_page)
{
$self = $_SERVER['PHP_SELF'];
$stmt = $this->db->prepare($query);
$stmt->execute();
$total_no_of_records = $stmt->rowCount();
if($total_no_of_records > 0)
{
?><ul class="pagination"><?php
$total_no_of_pages=ceil($total_no_of_records/$records_per_page);
$current_page=1;
if(isset($_GET["page_no"]))
{
$current_page=$_GET["page_no"];
}
if($current_page!=1)
{
$previous =$current_page-1;
echo "<li><a href='".$self."?page_no=1'>First</a></li>";
echo "<li><a href='".$self."?page_no=".$previous."'>Previous</a></li>";
}
for($i=1;$i<=$total_no_of_pages;$i++)
{
if($i==$current_page)
{
echo "<li><a href='".$self."?page_no=".$i."' style='color:red;'>".$i."</a></li>";
}
else
{
echo "<li><a href='".$self."?page_no=".$i."'>".$i."</a></li>";
}
}
if($current_page!=$total_no_of_pages)
{
$next=$current_page+1;
echo "<li><a href='".$self."?page_no=".$next."'>Next</a></li>";
echo "<li><a href='".$self."?page_no=".$total_no_of_pages."'>Last</a></li>";
}
?></ul><?php
}
}
/* paging */
}
add-data.php
<?php
include_once 'dbconfig.php';
if(isset($_POST['btn-save']))
{
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$email = $_POST['email_id'];
$contact = $_POST['contact_no'];
if($crud->create($fname,$lname,$email,$contact))
{
header("Location: add-data.php?inserted");
}
else
{
header("Location: add-data.php?failure");
}
}
?>
<?php include_once 'header.php'; ?>
<div class="clearfix"></div>
<?php
if(isset($_GET['inserted']))
{
?>
<div class="container">
<div class="alert alert-info">
<strong>WOW!</strong> Record was inserted successfully HOME!
</div>
</div>
<?php
}
else if(isset($_GET['failure']))
{
?>
<div class="container">
<div class="alert alert-warning">
<strong>SORRY!</strong> ERROR while inserting record !
</div>
</div>
<?php
}
?>
<div class="clearfix"></div><br />
<div class="container">
<form method='post'>
<table class='table table-bordered'>
<tr>
<td>First Name</td>
<td><input type='text' name='first_name' class='form-control' required></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type='text' name='last_name' class='form-control' required></td>
</tr>
<tr>
<td>Your E-mail ID</td>
<td><input type='text' name='email_id' class='form-control' required></td>
</tr>
<tr>
<td>Contact No</td>
<td><input type='text' name='contact_no' class='form-control' required></td>
</tr>
<tr>
<td colspan="2">
<button type="submit" class="btn btn-primary" name="btn-save">
<span class="glyphicon glyphicon-plus"></span> Create New Record
</button>
<i class="glyphicon glyphicon-backward"></i> Back to index
</td>
</tr>
</table>
</form>
</div>
<?php include_once 'footer.php'; ?>
edit-data.php
<?php
include_once 'dbconfig.php';
if(isset($_POST['btn-update']))
{
$id = $_GET['edit_id'];
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$email = $_POST['email_id'];
$contact = $_POST['contact_no'];
if($crud->update($id,$fname,$lname,$email,$contact))
{
$msg = "<div class='alert alert-info'>
<strong>WOW!</strong> Record was updated successfully <a href='index.php'>HOME</a>!
</div>";
}
else
{
$msg = "<div class='alert alert-warning'>
<strong>SORRY!</strong> ERROR while updating record !
</div>";
}
}
if(isset($_GET['edit_id']))
{
$id = $_GET['edit_id'];
extract($crud->getID($id));
}
?>
<?php include_once 'header.php'; ?>
<div class="clearfix"></div>
<div class="container">
<?php
if(isset($msg))
{
echo $msg;
}
?>
</div>
<div class="clearfix"></div><br />
<div class="container">
<form method='post'>
<table class='table table-bordered'>
<tr>
<td>First Name</td>
<td><input type='text' name='first_name' class='form-control' value="<?php echo $first_name; ?>" required></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type='text' name='last_name' class='form-control' value="<?php echo $last_name; ?>" required></td>
</tr>
<tr>
<td>Your E-mail ID</td>
<td><input type='text' name='email_id' class='form-control' value="<?php echo $email_id; ?>" required></td>
</tr>
<tr>
<td>Contact No</td>
<td><input type='text' name='contact_no' class='form-control' value="<?php echo $contact_no; ?>" required></td>
</tr>
<tr>
<td colspan="2">
<button type="submit" class="btn btn-primary" name="btn-update">
<span class="glyphicon glyphicon-edit"></span> Update this Record
</button>
<i class="glyphicon glyphicon-backward"></i> CANCEL
</td>
</tr>
</table>
</form>
</div>
<?php include_once 'footer.php'; ?>
delete.php
<?php
include_once 'dbconfig.php';
if(isset($_POST['btn-del']))
{
$id = $_GET['delete_id'];
$crud->delete($id);
header("Location: delete.php?deleted");
}
?>
<?php include_once 'header.php'; ?>
<div class="clearfix"></div>
<div class="container">
<?php
if(isset($_GET['deleted']))
{
?>
<div class="alert alert-success">
<strong>Success!</strong> record was deleted...
</div>
<?php
}
else
{
?>
<div class="alert alert-danger">
<strong>Sure !</strong> to remove the following record ?
</div>
<?php
}
?>
</div>
<div class="clearfix"></div>
<div class="container">
<?php
if(isset($_GET['delete_id']))
{
?>
<table class='table table-bordered'>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>E - mail ID</th>
<th>Gender</th>
</tr>
<?php
$stmt = $DB_con->prepare("SELECT * FROM tbl_users WHERE id=:id");
$stmt->execute(array(":id"=>$_GET['delete_id']));
while($row=$stmt->fetch(PDO::FETCH_BOTH))
{
?>
<tr>
<td><?php print($row['id']); ?></td>
<td><?php print($row['first_name']); ?></td>
<td><?php print($row['last_name']); ?></td>
<td><?php print($row['email_id']); ?></td>
<td><?php print($row['contact_no']); ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</div>
<div class="container">
<p>
<?php
if(isset($_GET['delete_id']))
{
?>
<form method="post">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
<button class="btn btn-large btn-primary" type="submit" name="btn-del"><i class="glyphicon glyphicon-trash"></i> YES</button>
<i class="glyphicon glyphicon-backward"></i> NO
</form>
<?php
}
else
{
?>
<i class="glyphicon glyphicon-backward"></i> Back to index
<?php
}
?>
</p>
</div>
<?php include_once 'footer.php'; ?>
MY SQL :
CREATE TABLE IF NOT EXISTS `tbl_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(25) NOT NULL, `last_name` varchar(25) NOT NULL, `email_id` varchar(50) NOT NULL, `contact_no` bigint(10) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=21
Still adding your selectbox and will update this answer soon.

Call php function when click a button

I have a code :
<?php
getPriceListHeader();
function getPriceListDetail($PriceListCode)
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = "SELECT * FROM pricelisdetail where pricelist_code='".$PriceListCode."'";
$results = $readConnection->fetchAll($query);
echo "<table id='tbdata'>
<thead>
<tr>
<th>Price List Code</th>
<th>Price List Name</th>
<th>Effective From</th>
<th>Effective To</th>
</tr>
</thead>
<tbody> ";
foreach ($results as $row)
{
echo "<tr>";
echo "<td> ".$row[entity_id];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
};
echo " </tbody>
</table> ";
}
function getPriceListHeader()
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM pricelistheader';
$results = $readConnection->fetchAll($query);
echo "
<h2>Price List</h2>
<div>
<h3>Please select Price List</h3>
<div>
<select class='element select large' id='pricelist' name='element_2'>";
foreach ($results as $row)
{
echo '<option value="' . $row[entity_id]. '">' . $row[sku] . '</option>';
}
echo "</select>
</div>
<input type='button' class='button' name='insert' value='Get Data' onclick='getPriceListDetail(pricelist.value)'/>
";
getPriceListDetail('');
}
?>
I have a dropdown list, a button, a table
When I select a value from dropdown list, then I click button , table will be filled data again. There are 2 method, getPriceListHeader(): load data header when load the page, getPriceListDetail : load data detail when click a button. I try to put event getPriceListDetail(value) to button, but when I click, nothing happens
Please help me how to do this.
Yes, you can call php via ajax request to server like this (very simple):
Note that the following code uses jQuery
jQuery.ajax({
type: "POST",
url: 'my_php_function.php',
dataType: 'name_the_data_type',
success: function (data) {
// here you will get the response your function
}
});
and my_php_function.php like this:
<?php
// here is your php code or function
?>
from the source How can I call PHP functions by JavaScript?
You can't attach PHP function to HTML. PHP is server-side language, so after it's displayed in users browser you can't refer to PHP again, unless you reload page.
There are 3 options I think you can do:
Reload page after changing select page and using GET prepare new data.
Send all data to user browser and than show only part of it related to selected option.
Use AJAX and ask server for new data in background.
Finally, I found out the way.It works for me. Now, I do not understand the code , I am trying to read and get it clearly.
Thanks all for your comments.
$to="";
$from="";
$show_order_statuses = 0;
$orserstatus = "";
$result_order = 0;
//var_dump($results);
//return;
if(!empty($_REQUEST['filter_type']))
{
$orders_row = array();
$filter_type = $_REQUEST['filter_type'];
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistitem where pricelist_code='".$filter_type."' ";
// $query = 'SELECT * FROM pricelistheader1';
$results = $readConnection->fetchAll($query);
foreach ($results as $rowid)
{
$result_order=10;
$orders_row[]=array($rowid['pricelist_code'],$rowid['product_code'],number_format( $rowid['unitprice'],2),$rowid['UOM']);
// $orders_row[]=array(1,1,1,1,1);
}
}
?>
<div id="anchor-content" class="middle">
<div id="page:main-container">
<div class="content-header">
<table cellspacing="0">
<tbody>
<tr>
<td style="width:50%;"><h3 class="icon-head head-report-sales-sales"><?php echo $this->__("Price List");?></h3></td>
<td class="form-buttons"><button style="" onclick="filterFormSubmit.submit()" class="scalable " type="button" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>"><span>Show Report</span></button></td>
</tr>
</tbody>
</table>
</div>
<div>
<div class="entry-edit">
<form method="get" action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" id="filter_form">
<?php /*?><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /><?php */?>
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Filter</h4>
<div class="form-buttons"></div>
</div>
<div id="sales_report_base_fieldset" class="fieldset">
<div class="hor-scroll">
<table cellspacing="0" class="form-list">
<tbody>
<tr>
<td class="label"><label for="sales_report_filter_type">Filter By <span class="required">*</span></label></td>
<td class="value">
<select class="required-entry select" name="filter_type" id="sales_report_filter_type" onchange="myFunction();">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistheader ";
$results = $readConnection->fetchAll($query);
$so=1;
foreach ($results as $row)
{
$selected='';
if ($filter_type==$row[pricelist_code])
$selected= ' selected=selected';
else
$selected='';
echo '<option value="' . $row[pricelist_code]. '" '.$selected.' >' . $row[pricelist_name].' '. $row[pricelist_code] . '</option>';
}
?>
</select>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect From </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_fromdate];
}
?>
</td>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect To </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_todate];
}
?>
</td>
</tr>
</tbody>
<script>
function myFunction() {
// document.getElementById("tbdata").deleteRow(1);
var rowCount = tbdata.rows.length;
for (var i = rowCount - 1; i > 0; i--) {
tbdata.deleteRow(i);
}
srt.value=pricelist.options[pricelist.selectedIndex].value;
";
//$('#tbdata').empty();
}
</script>
</table>
</div>
</div>
</form>
</div>
<script type="text/javascript">
//<![CDATA[
var filterFormSubmit = new varienForm('filter_form');
//]]>
</script>
<script type="text/javascript"> new FormElementDependenceController({"sales_report_order_statuses":{"sales_report_show_order_statuses":"1"}}); </script>
<style type="text/css">
.no-display{display:none;}
</style>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form_customer">
<input name="form_key_customer" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmitcustomer = new varienForm('csv_form_customer');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export_customer" name="sales_order_grid_export_customer">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmitcustomer.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Cust Code</span></th>
<th class=" no-link"><span class="nobr">Cust Name</span></th>
</tr>
</thead>
<tbody id="">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM " . $resource->getTableName('catalog/product');;
$customercount=0;
$customerresults = $readConnection->fetchAll($query);
$customerresults = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('erp_pricelistcode_1', $filter_type)
// ->addFieldToSelect (array('created_at','customer_id','increment_id','updated_at','status','entity_id','state'))
;
// ->addAttributeToFilter('erp_pricelistcode_1','00')->load();
$so=1;
foreach ($customerresults as $row) {
$customercount++;
}
// var_dump(#$customerresults);
if($customercount>0){
foreach($customerresults as $singlerows){
$cot=0;
{
echo "<tr>";
{
$cot++;
?>
<td>
<?php
echo $singlerows->getData('erp_pricelistcode_1');
?>
</td>
<td>
<?php
echo $singlerows->getFirstname();
?>
</td>
<td>
<?php
echo $singlerows->getName();
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmit = new varienForm('csv_form');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export" name="sales_order_grid_export">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmit.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Product Code</span></th>
<th class=" no-link"><span class="nobr">Unit Price</span></th>
<th class=" no-link"><span class="nobr">UOM</span></th>
</tr>
</thead>
<tbody id="">
<?php
$cot=0;
if(count($orders_row)>0){
foreach($orders_row as $singlerows){
$cot=0;
if(!empty($singlerows)){
echo "<tr>";
foreach($singlerows as $value){
$cot++;
?>
<td>
<?php
if ($cot==3 )
echo "<div style='float:right;width:30%;'>";
echo $value;
echo "</div>";
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>

Filter Table by Dropdown and date/export to excel

Good afternoon Team,
I've been searching the internet/stackoverflow for a long time now and i am unable to wrap my head around one issue that keeps bothering me for quite some time.Tried to avoid it ( you don't want to see my browser history).
The thing is , this issue leads to another and maybe some advices from you might help.
Before TL;DR - here is the issue:
Ingredients:
1. 1 database (phpmyadmin)
2. 1 table
3. 3 files(filter.html/ raport.php / export.php )
Issue that leads to another :
What i am trying to do is , i want to filter the results from the table by date-range( which works ) and also by the dropdown (which does not work).
Please see code from filter.html:
<html>
<head>
<title> Raport</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
</head>
<body>
<br /><br />
<div class="container" style="width:900px;">
<h2 align="center"> Raport</h2>
<h3 align="center">Order Data</h3><br />
<div class="col-md-3">
<input type="text" name="from_date" id="from_date" class="form-control" placeholder="From Date" />
</div>
<div class="col-md-3">
<input type="text" name="to_date" id="to_date" class="form-control" placeholder="To Date" />
</div>
<div class="col-md-4">
<select type="text" name="team" id="team" class="form-control ">
<option value="">Select team</option>
<option value="pt">pt</option>
<option value="it">it</option>
</select>
</div>
<div class="col-md-4">
<input type="button" name="filter" id="filter" value="Filter" class="btn btn-info" />
</div>
<form method="post" action="export.php" id="export_form">
<input type="hidden" name="from_date" id="from_date1" class="form-control" />
<input type="hidden" name="to_date" id="to_date1" class="form-control" />
<input type="submit" name="export" id="export_btn" class="btn btn-success" value="Export" />
</form>
<div style="clear:both"></div>
<br />
<div id="order_table">
<table class="table table-bordered">
<tr>
<th width="5%">Id</th>
<th width="30%">name1</th>
<th width="43%">name2</th>
<th width="43%">name3</th>
<th width="10%">name4</th>
<th width="12%">name5</th>
<th width="12%">name6</th>
<th width="12%">name7</th>
<th width="12%">name8</th>
</tr>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['name1'];?></td>
<td><?php echo $row['name2'];?></td>
<td><?php echo $row['name3'];?></td>
<td><?php echo $row['name4'];?></td>
<td><?php echo $row['name5'];?></td>
<td><?php echo $row['name6'];?></td>
<td><?php echo $row['name7'];?></td>
<td><?php echo $row['name8'];?></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd'
});
$(function(){
$("#from_date").datepicker({
onSelect: function(dateText, inst){
$('#from_date1').val(dateText);
}
});
$("#to_date").datepicker({
onSelect: function(dateText, inst){
$('#to_date1').val(dateText);
}
});
});
if($("#from_date").val() != ''){
$('#from_date1').val($("#from_date").val());
}
if($("#to_date").val() != ''){
$('#to_date1').val($("#to_date").val());
}
$('#filter').click(function(){
var from_date = $('#from_date').val();
var to_date = $('#to_date').val();
if(from_date != '' && to_date != '')
{
$.ajax({
url:"raport.php",
method:"POST",
data:{from_date:from_date, to_date:to_date},
success:function(data)
{
$('#order_table').html(data);
}
});
}
else
{
alert("Please Select Date");
}
});
});
</script>
Please see code from raport.php:
<?php
if(isset($_POST["from_date"], $_POST["to_date"]))
{
$connect = mysqli_connect("localhost", "root", "", "database");
$output = '';
$query = "
SELECT * FROM fp_data
WHERE submitdate BETWEEN '".$_POST["from_date"]."' AND '".$_POST["to_date"]."'
";
$result = mysqli_query($connect, $query);
$output .= '
<table class="table table-bordered">
<tr>
<th width="5%">Id</th>
<th width="30%">name1</th>
<th width="43%">name2</th>
<th width="43%">name3</th>
<th width="10%">name4</th>
<th width="12%">name5</th>
<th width="12%">name6</th>
<th width="12%">name7</th>
<th width="12%">name8</th>
</tr>
';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["id"].'</td>
<td>'.$row["name1"].'</td>
<td>'.$row["name2"].'</td>
<td>'.$row["name3"].'</td>
<td>'.$row["name4"].'</td>
<td>'.$row["name5"].'</td>
<td>'.$row["name6"].'</td>
<td>'.$row["name7"].'</td>
<td>'.$row["name8"].'</td>
</tr>
';
}
}
else
{
$output .= '
<tr>
<td colspan="12">No data found</td>
</tr>
';
}
$output .= '</table>';
echo $output;
}
?>
Please see code from export.php:
<?php
//export.php
$connect = mysqli_connect("localhost", "root", "", "database");
$output = '';
if(isset($_POST["export"]))
{
$from_date = $_POST["from_date"];
if(!empty($from_date)) {
$from_date = $from_date." 00:00:00";
} else{
$from_date = date("Y-m-d")." 00:00:00";
}
$to_date = $_POST["to_date"];
if(!empty($to_date)) {
$to_date = $to_date." 23:59:59";
} else {
$to_date = date("Y-m-d")." 23:59:59";
}
$query = "SELECT * FROM fp_data WHERE submitdate >= '$from_date' AND submitdate <= '$to_date'";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<table class="table" bordered="1" style="border: 1px solid #000">
<tr>
<th>id</th>
<th>name1</th>
<th>name2</th>
<th>name3</th>
<th>name4</th>
<th>name5</th>
<th>name6</th>
<th>name7</th>
<th>name8</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["id"].'</td>
<td>'.$row["name1"].'</td>
<td>'.$row["name2"].'</td>
<td>'.$row["name3"].'</td>
<td>'.$row["name4"].'</td>
<td>'.$row["name5"].'</td>
<td>'.$row["name6"].'</td>
<td>'.$row["name7"].'</td>
<td>'.$row["name8"].'</td>
</tr>
';
}
$output .= '</table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=raportlte.xls');
echo $output;
}
}
?>
The other issue is how do i export it?
All in all is that i want to filter the data by date-range and also by the dropdown and then export what is in the table to excel.
Any help is apreciated.

Categories