<div class="card-header py-3">
<h4 class="m-2 font-weight-bold text-primary">Asset Approval List</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Asset</th>
<th>Serial Number</th>
<th>Model Name</th>
<th>Owner ID</th>
<th>Owner Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<script>
function approval(){
window.location.href = "AddAssetApproval.php";
}
</script>
<?php
$query = "SELECT * FROM waiting_approval";
$result = mysqli_query($conn, $query) or die (mysqli_error($conn));
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>'. $row['Category'].'</td>';
echo '<td>'. $row['SerialNumber'].'</td>';
echo '<td>'. $row['ModelName'].'</td>';
echo '<td>'. $row['OwnerID'].'</td>';
echo '<td>'. $row['OwnerName'].'</td>';
echo '<td>'. $row['Description'].'</td>';
echo '<td><input type="button" value = "View" onclick="approval()"></td>';
echo '</tr> ';
}
?>
<div class="title">
Add Asset Approval Form
</div>
<div class="form">
<div class="inputfield">
<label>Category</label>
<input type="text" class="input" name="Category">
</div>
<div class="inputfield">
<label>Serial Number</label>
<input type="text" class="input" name="SN">
</div>
<div class="inputfield">
<label>Model Name</label>
<input type="text" class="input" name="Model Name">
</div>
<div class="inputfield">
<label>Owner ID</label>
<input type="text" class="input" name="OID">
</div>
<div class="inputfield">
<label>Owner Name</label>
<input type="text" class="input" name="OName">
</div>
<div class="inputfield">
<label>Description</label>
<input type="text" class="input" name="Desc">
</div>
Asset Approval List is a table with lots of row of data and a button, after clicking the button, it will link to Asset Approval Form. I would like to fetch the data from the same row in Asset Approval List to my Asset Approval Form. The data in the table of Asset Approval List is fetched from mysql phpmyadmin. Any idea how to link the same data to Asset Approval Form?
This is my Asset Approval List
This is my Asset Approval Form
Assuming there's a unique ID column in the table, you should include that in the call to approval():
echo '<td><input type="button" value = "View" onclick="approval(\'' . $row['SerialNumber'] . '\')"></td>';
Then change approval() to include the ID in the URL.
function approval(serial){
window.location.href = "AddAssetApproval.php?serial=" + serial;
}
And AddAssetApproval.php should use $_GET['serial'] to display the appropriate approval form for that serial number.
$stmt = $conn->prepare("SELECT * FROM waiting_approval WHERE SerialNumber = ?");
$stmt->bind_param("i", $_GET['serial']);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
Related
officer_cashier.php
This is my modal form I want to display a table upon clicking the button add from cashier_template.php in DIV tag id=add_table
<div class="modal fade" id="fee_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Process payment</h5>
<button type="button" class="close get_close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form method="POST" action="officer_cashier.php" id="reg">
<fieldset class="scheduler-border">
<legend class="scheduler-border">Student information</legend>
<input type="hidden" class="form-control" id="id" name="id">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" readonly="readonly">
</div>
<div class="form-group">
<label for="course">Course</label>
<input type="text" class="form-control" id="course" name="course" readonly="readonly">
</div>
<div class="form-group">
<label for="sem">Semester</label>
<input type="text" class="form-control" id="sem" name="sem" readonly="readonly">
</div>
<div class="form-group">
<label for="year">Year</label>
<input type="text" class="form-control" id="year" name="year" readonly="readonly">
</div>
</fieldset>
<button class="btn btn-sucess add_fees" id="add_fees">add</button >
<div class="form-group" id="display_table"></div><!-- I want to display the table inside of this DIV tag -->
</form>
</div>
</div>
</div>
</div>
script
This is my AJAX the course,sem,year data is what i need to display the table, so if those three fetch successfully I want to display it in my DIV tag #display_table
$(document).on('click', '.add_fees', function(){
$.ajax({
type: "post",
url: "../templates/cashier_template.php",
data: {
"course": $("#course").val(),
"semester": $("#sem").val(),
"year": $("#year").val(),
},
success: function(data) {
$("#display_table").html(data);
}
});
});
cashier_template.php
This is the cashier template once the AJAX pass the data and matcher the query it should display in modal but I wasnt getting
<?php
ob_start();
include("../include/userlogin.php");
if(!isset($_SESSION))
{
session_start();
}
if($_SESSION['usertype'] != 1){
header("location: login.php?success=1");
$_SESSION['message'] = "You cannot access this page unless you are a officer!";
}
ob_end_flush();
$yearId = $_POST['year'];
$courseId = $_POST['course'];
$semesterId = $_POST['semester'];
$result = $connect->query("SELECT id, total_fees, fee_names FROM manage_fees WHERE year_lvl = '$yearId' AND course = '$courseId' AND semester = '$semesterId'") or die($connect->error());
while($row = $result->fetch_assoc()):
?>
<div class="table-sorting table-responsive" style="margin-top: 1rem;">
<table class="table table-striped table-bordered table-hover" id="table1">
<thead>
<tr class="p-4">
<th scope="col">Select</th>
<th scope="col">School fees</th>
<th scope="col">Amount</th>
<th scope="col">type</th>
</tr>
</thead>
<tbody>
<?php
$result = $connect->query("SELECT * FROM fees;") or die($connect->error());
while($row = $result->fetch_assoc()){
?>
<tr>
<td>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input check_amount" name="local_fees">
<label class="custom-control-label" for="check_amount"></label>
</div>
</td>
<td name="selected_fees"><?php echo $row['fee_name']; ?></td>
<td name="amount"><?php echo $row['amount']; ?></td>
<td><?php echo $row['type']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php endwhile; ?>
<script src="../js/datable.js"></script>
You are overwriting the $result object (and subsequently the $row obect) when you query fees. So the big loop at the top:
while($row = $result->fetch_assoc()):
is getting overwritten down the line by
$result = $connect->query("SELECT * FROM fees;");
while($row = $result->fetch_assoc()){
But really, there's no need to query FEES in every loop. Why not first get all the fees data into an array, then just access it in the other loop. So first, at the top of your php script:
<?php
$fees=array();
$result = $connect->query("SELECT * FROM fees;");
while($row = $result->fetch_assoc()){ $fees[]=$row; }
?>
Then in your main loop
<?php
foreach ($fees as $fee) {
?>
...
<td name="selected_fees"><?php echo $fee['fee_name']; ?></td>
<td name="amount"><?php echo $fee['amount']; ?></td>
<td><?php echo $fee['type']; ?></td>
</tr>
<?php } ?>
I have some data in my mysql database which I am displaying in table using PHP like below
$requirement_qry="SELECT t1.*, t2.id as unit_id, t2.name as unit_name FROM `tbl_requirements`
t1 INNER JOIN tbl_units AS t2 on unit_type = t2.id AND project_id='".$_GET['project_id']."' AND user_id='".$userid."'";
$requirement_result=mysqli_query($mysqli,$requirement_qry);
<form action="" name="addeditcategory" method="post" class="form form-horizontal" enctype="multipart/form-data">
<input type="hidden" name="project_id" value="<?php echo $_GET['project_id'];?>" />
<div class="section">
<div class="section-body">
<div class="form-group">
<label class="col-md-3 control-label" >Project Name :-</label>
<div class="col-md-6">
<input type="text" name="name" id="name" value="<?php if(isset($_GET['project_id'])){echo $row['name'];}?> " class="form-control" disabled>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" >Location :-</label>
<div class="col-md-6">
<input type="text" name="location" id="location" value="<?php if(isset($_GET['project_id'])){echo $row['location'];}?> " class="form-control" disabled>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Project Status :-</label>
<div class="col-md-6">
<select name="status" id="status" class="select2" disabled>
<?php if (!isset($_GET['project_id'])) { ?>
<option value="1">--Project Status--</option>
<?php } ?>
<option value="1" <?php echo $row['status'] == '1' ? 'selected' : ''; ?> >Open</option>
<option value="2" <?php echo $row['status'] == '2' ? 'selected' : ''; ?> >Closed</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label class="control-label">Project Details :-</label>
</div>
<div class="col-md-6">
<textarea name="details" id="details" rows="4" class="form-control" disabled><?php echo stripslashes($row['details']);?></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label class="control-label">Project Requirements :-</label>
</div>
<div class="col-md-6">
<table id="t01">
<thead>
<tr>
<th>#</th>
<th>Requirements</th>
<th>Required</th>
<th>Sent</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
while ($row1 = mysqli_fetch_array($requirement_result))
{
$id = $row1['id'];
$unit_name = $row1['unit_name'];
echo '<input type="hidden" name="reqId" id= "reqId" value="'.$id.'" />';
echo '<tr>
<td>'.$no.'</td>
<td>'.$row1['name'].'</td>
<td>'.$row1['unit_required']." ".$unit_name.'</td>
<td><input type="number" id = "received" name = "received" value ="'.$row1['unit_received'].'"/></td>
<td><button type="submit" name="submit" class="btn btn-primary" style="padding:5px 10px;">Submit</button></td>
</tr>';
$no++;
}?>
</tbody>
</table>
</div>
</div>
</div>
</form>
Above code is properly displaying my data. I have one field value from row need to update using submit button. Its working fine if there only one row...if there multiple row, its not updating data of it except last row.
My submit code is like below
if(isset($_POST['submit']) and isset($_POST['project_id']))
{
$projectId = $_GET['project_id'];
$data = array(
'unit_received' => $_POST['received']
);
$unit_edit=Update('tbl_requirements', $data, " WHERE id = '".$_POST['reqId']."'");
print_r($unit_edit);
echo $unit_edit;
if ($unit_edit > 0)
{
$_SESSION['msg']="11";
header( "Location:view_open_project.php?project_id=".$_POST['project_id']);
exit;
}
}
I am little new in PHP, Let me know if someone can help me for solve the bug.
Thanks a lot :)
As #Saji has already stated, you are replicating your name through the loop.You should rather use
echo '<input type="hidden" name="reqId[]" id= "reqId" value="'.$id.'" />';
Note the [] brackets that were appended so that you create an array of names.
To update, you need a loop like
for($i=0;$i<count($_POST['reqId']);$i++){
$unit_edit=Update('tbl_requirements', $data, " WHERE id = '".$_POST['reqId'][$i]."'");
}
What you can do is just create a hidden form where you will keep original elements. When the save button click you just find the actual value and set this to the elements inside hidden form, then trigger the submit button inside hidden form.
Note the changes I have done on your code.
1.Removed the hidden element reqId from inside loop.
2.Given a class name to the button inside loop and changed the button type from submit to button. Added data attribute data-id="'.$id.'".
3.The input received inside the loop has given unique id and name by concatenated the $id.
4.Created hidden form with hidden input in it. It has your actual input names.
5.Created a jquery function to attach click event to the button inside loop.
6.Moved the hidden element project_id to inside hidden form.
Now see the below code for more details. Hope this will help you..
<form action="" name="addeditcategory" method="post" class="form form-horizontal" enctype="multipart/form-data">
<input type="hidden" name="project_id" value="<?php echo $_GET['project_id']; ?>"/>
<div class="section">
<div class="section-body">
<div class="form-group">
<label class="col-md-3 control-label">Project Name :-</label>
<div class="col-md-6">
<input type="text" name="name" id="name" value="<?php if (isset($_GET['project_id'])) {
echo $row['name'];
} ?> " class="form-control" disabled>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Location :-</label>
<div class="col-md-6">
<input type="text" name="location" id="location" value="<?php if (isset($_GET['project_id'])) {
echo $row['location'];
} ?> " class="form-control" disabled>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Project Status :-</label>
<div class="col-md-6">
<select name="status" id="status" class="select2" disabled>
<?php if (!isset($_GET['project_id'])) { ?>
<option value="1">--Project Status--</option>
<?php } ?>
<option value="1" <?php echo $row['status'] == '1' ? 'selected' : ''; ?> >Open</option>
<option value="2" <?php echo $row['status'] == '2' ? 'selected' : ''; ?> >Closed</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label class="control-label">Project Details :-</label>
</div>
<div class="col-md-6">
<textarea name="details" id="details" rows="4" class="form-control"
disabled><?php echo stripslashes($row['details']); ?></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label class="control-label">Project Requirements :-</label>
</div>
<div class="col-md-6">
<table id="t01">
<thead>
<tr>
<th>#</th>
<th>Requirements</th>
<th>Required</th>
<th>Sent</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
while ($row1 = mysqli_fetch_array($requirement_result)) {
$id = $row1['id'];
$unit_name = $row1['unit_name'];
echo '<tr>
<td>' . $no . '</td>
<td>' . $row1['name'] . '</td>
<td>' . $row1['unit_required'] . " " . $unit_name . '</td>
<td><input type="number" id = "received' . $id . '" name = "received' . $id . '" value ="' . $row1['unit_received'] . '"/></td>
<td><button type="button" name="submit" class="btn btn-primary submit-click" data-id="' . $id . '" style="padding:5px 10px;">Submit</button></td>
</tr>';
$no++;
} ?>
</tbody>
</table>
</div>
</div>
</div>
</form>
<form action="" id="addeditcategory_temp" name="addeditcategory_temp" method="post" class="form form-horizontal" enctype="multipart/form-data" style="display:none;>
<input type="hidden" name="project_id" value="<?php echo $_GET['project_id']; ?>"/>
<input type="hidden" name="reqId" id= "reqId" value="" />
<input type="number" id = "received" name = "received" value ="">
<button id="submitButton" type="submit" name="submit" class="btn btn-primary" style="padding:5px 10px;">
</form>
<script>
$(document).ready(function(e){
$('.submit-click').off('click').on('click', function(e){
var reqId = $(this).data('id');
var received = $('#received'+reqId).val();
var form = $('#addeditcategory_temp');
form.find('#reqId').val(reqId);
form.find('#received').val(received);
form.find('#submitButton').trigger('click');
})
});
</script>
I want to print the display table from the HTML page. For example, I search 'from what id' to 'to what id'. After clicking on the search button, it will display the tables that have the details. I want to print that table in PDF format. So, do I need to create the table again in the PDF?
<form class="form-horizontal" action="trypdf.php" method="POST">
<div class="form-group form-group-sm">
<label for="inputName" class="control-label col-xs-2" style="margin-left:10%; margin-top:4%; font-size:15px;">Em Part No From:</label>
<div class="col-xs-3">
<input type="text" id="srt" name="from" placeholder="From EmPartNo" required="" style="margin-left:-7%; margin-top:18%; text-align:center;"
value="<?php echo $empartno_pass1;?>"/>
</div>
<div class="col-xs-1">
<button type="button" name="from" data-toggle="modal" data-target="#search1" data-id="from" style="margin-left:-190%; margin-top:70%;">S</button>
</div>
<label for="inputName" class="control-label col-xs-1" style="margin-left:-15%; margin-top:4%; font-size:15px;">To:</label>
<div class="col-xs-3">
<input type="text" id="srt2" name="to" placeholder="To EmPartNo" style="margin-left:-36%; margin-top:18%; text-align:center;"
value="<?php echo $empartno_pass2;?>"/>
</div>
<div class="col-xs-1">
<button type="button" name="to" data-toggle="modal" data-target="#search1" data-id="to" style="margin-left:-302%; margin-top:70%;">S</button>
</div>
Back to Menu
<center><input type="submit" value="Search" class="btn btn-primary" style="margin-left:-2%; width:100px; height:30px; text-align:center;"></center><br>
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>EmPartNo</th>
<th>Supplier No</th>
<th>Supplier Cost</th>
<th>Description</th>
<th>Foreign Currency</th>
<th>Item Cost</th>
<th>Admin Cost</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$counter = 1;
$total = 0;
if (isset($count) and ($count > 0)) {
while($row = mysqli_fetch_assoc($result)){
$emPartNo = $row['emPartNo'];
$supplierPartNo = $row['supplierPartNo'];
$supplierCostPrice =$row['supplierCostPrice'];
$description = $row['description'];
$foreignCurrency =$row['foreignCurrency'];
$itemCost = $row['itemCost'];
$adminCost =$row['adminCost'];
$cost = $row['cost'];
echo"<tr>
<td>{$row['emPartNo']}</td>
<td>{$row['supplierPartNo']}</td>
<td align='right'>".number_format($row['supplierCostPrice'],2)."</td>
<td>{$row['description']}</td>
<td>{$row['foreignCurrency']}</td>
<td align='right'>".number_format($row['itemCost'],2)."</td>
<td align='right'>".number_format($row['adminCost'],2)."</td>
<td align='right'>".number_format($row['cost'],2)."</td>
</tr>";
}
mysqli_free_result($result);
}
?>
</tr>
</tbody>
</table>
</form>
Here is the example of an image that I want to display in PDF.
I am inserting multiple line values from a html table form in to sql but it's only inserting the last table form value in my database. I can't figure out where the problem is.
Can you help me out with this?
This is my PHP:
$result = mysql_query("SELECT * FROM ex_marks WHERE session='$session' and cl_name='$cl_name' and cl_section='$cl_section' and subject='$subj' and exam='$exam' and date='$date' and roll_no='$rollno' and obtainmarks='$marks'");
if (mysql_num_rows($result) == 0)
{
mysql_query("INSERT INTO ex_marks(mid, session, cl_name, cl_section, name, fname, status, date, exam, roll_no, subject, obtainmarks, maxmarks, passmarks)
VALUES('', '$session', '$cl_name', '$cl_section', '$name','$fname', '$attendance', '$date', '$exam', '$rollno', '$subj','$marks','$maxmarks','$passmarks')") or die(mysql_error());
echo "<script type='text/javascript'>alert('Submitted Successfully!')</script>";
}
else
{
echo "<script type='text/javascript'>alert('Already Exist!')</script>";
}
}
And this is the form where values are inserted:
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">ASSIGN MARKS</h1>
<div class="col-lg-6">
<div class="panel">
<form method="post">
<!--<div class="form-group">
<input type="text" size="15" name="date" id="name[]" class="tcal form-control" placeholder="EXAM DATE" required="required"/>
</div>-->
<div class="form-group">
<input class="form-control" type="text" size="17" name="maxmarks" placeholder="TOTAL MARKS" required="required"/>
</div>
<div class="form-group">
<input class="form-control" type="text" size="17" name="passmarks" placeholder="PASS MARKS" required="required"/>
</div>
<button name="btn_sub" type="submit" class="btn btn-info">SUBMIT</button>
</div>
</div>
<!-- /.col-lg-12 -->
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Session :
<?php
$session=$_GET['session'];
echo $session;?>
Class :
<?php
$cl_name=$_GET['cl_name'];
echo $cl_name;?>
Section :
<?php
$cl_section=$_GET['cl_section'];
echo $cl_section;?>
Subject :
<?php
$subj = $_GET['subj'];
echo $subj;?>
Exam Date :
<?php
$date=$_GET['date'];
echo $date;?>
Exam :
<?php
$exam=$_GET['exam'];
echo $exam;?>
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>NO.</th>
<th class="text-center">NAME</th>
<th class="text-center">ROLL NO</th>
<th class="text-center">FATHER NAME</th>
<th class="text-center">SCORED MARKS</th>
<th class="text-center">ATTENDANCE</th>
</tr>
</thead>
<tbody>
<?php
$key="";
if(isset($_POST['searchtxt']))
$key=$_POST['searchtxt'];
if($key !="")
$sql_sel1=mysql_query("SElECT * FROM ex_attendance WHERE session like '%$key%' and cl_name like '%$key%' and cl_section like '%$key%'");
else
$sql_sel1=mysql_query("select * from ex_attendance where session='$session' and cl_name='$cl_name' and cl_section='$cl_section' and exam='$exam' and date='$date' and subject='$subj'");
$i=0;
while($row1=mysql_fetch_array($sql_sel1))
{
$i++;
$color=($i%2==0)?"lightblue":"white";
?>
<tr class="odd gradeX">
<td><?php echo $i;?></td>
<td align="center"><input size="17" type="text" name="name" value="<?php echo $row1['f_name']." ".$row1['m_name']." ".$row1['l_name'];?>" readonly="readonly"/></td>
<td align="center"><input size="13" type="text" name="rollno" value="<?php echo $row1['roll_no']?>" readonly="readonly"/></td>
<td align="center"><input size="17" type="text" name="fname" value="<?php echo $row1['fname']?>" readonly="readonly"/></td>
<td align="center"><input size="17" type="text" name="marks" required="required"/></td>
<td align="center"><input size="17" type="text" name="attendance" id="name[]" value="<?php echo $row1['status'];?>" readonly="readonly"/></td>
</tr>
<?php }?>
</form>
</tbody>
</table>
</div>
</div>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
</div>
I have attendance record database
id | emp_id | attendance_date.
I inserted attendance_date by varchar(200).I want to retrieve dates between startdate and enddate if I choose datetime picker.My date format is m/d/Y.
If I retrieve 04/1/2015 and 04/30/2015,it isn't displayed.But If I retrieve
12/1/2014 and 12/31/2014,record is displayed.The problem is the month.It have unnecessary zero in front of month.How can I do that?
Please help me?Database is like that.
id emp_id attendance_date
1 1 10/4/2014 10:36
2 1 10/30/2014 9:36
attendanceRecord.php
<form enctype="multipart/form-data" method="post" class="form-inline" role="form" action="attendance_search.php">
<!--Start Date-->
<div class="">
<div class="form-group required">
<label for="startdate" class="control-label">Start Date:</label>
<input class="form-control" placeholder="Choose Date " type="text" id="datepicker-8" name="startdate" required="required" />
</div>
</div><br/><br/>
<!--End Date-->
<div class="">
<div class="form-group required">
<label for="enddate" class="control-label">End Date:</label>
<input class="form-control" placeholder="Choose Date " type="text" id="datepicker-9" name="enddate" required="required" />
</div>
</div>
<!--Create Button-->
<div class=""> <br/>
<input class="btn btn-success" type="submit" value="Search" />
</div>
</form>
**attendance_search.php**
<form method="post" name="salaryform" action="" class="form-vertical">
<div class="table table-hover">
<table border="1" cellspacing="0" class="table" >
<tr class="success" >
<th>Employee ID</th>
<th>Date</th>
<th>Timein Timeout</th>
</tr>
<?php
include 'connect.php';
error_reporting(E_ALL ^ E_NOTICE);
if(!empty($_POST)){
$startdate= mysql_real_escape_string(date( "m/d/Y H:i:s",strtotime($_POST["startdate"])));
$enddate= mysql_real_escape_string(date("m/d/Y H:i:s",strtotime($_POST["enddate"])));
$sql="SELECT * FROM attendance2 WHERE attendance_date between '".$startdate."' and '".$enddate."'";
$retval = mysql_query($sql);
if (!$retval) {
die('Could not get data: ' . mysql_error());
}
while ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
echo '<tr class="active">';
echo '<td >'.$row['emp_id'].'</td>';
echo '<td>'.$row['attendance_date'].'</td>';
echo '<td>'.$row['timein_timeout'].'</td>';
}
echo '</tr>';
echo '</table>';
}
?>
</table>
</div>
</form>
If you don't need the time of start date and end date then you could do something like this,
$startdate = mysql_real_escape_string(date( "m/d/Y",strtotime($_POST["startdate"])));
$enddate = mysql_real_escape_string(date("m/d/Y",strtotime($_POST["enddate"])));
$sql="SELECT * FROM attendance2 WHERE date(attendance_date) between '".$startdate."' and '".$enddate."'";