I have table from foreach, in this table i create submit with ajax (id="detail"), but why when i submit i just get first row, when i click second row value, i get first row value not second row value ?
<form action="<?php echo base_url() ?>index.php/stock_opname/proses_detail" method="post">
<table class="table table-striped">
<thead>
<tr>
<th>No</th>
<th>SO No</th>
<th>Opname Date</th>
<th>Warehouse</th>
<th>Type</th>
<th>Approve</th>
<th>Close period</th>
<th>Detail</th>
</tr>
</thead>
<tbody>
<?php $no=1; foreach ($show as $key) { ?>
<tr>
<td><?php echo $no ?></td>
<td><input type="text" id="sono" value="<?php echo $key->sono ?>"></td>
<td><input type="text" id="opnamedate" value="<?php echo $key->opnamedate ?>"></td>
<td><input type="text" id="warehousecode" value="<?php echo $key->warehousecode ?>"></td>
<td><input type="text" id="stocktypeid" value="<?php echo $key->stocktypeid ?>"></td>
<td></td>
<td></td>
<td>Detail</td>
</tr>
<?php $no++;} ?>
</tbody>
</table>
</form>
<script type="text/javascript">
//Ajax Load data from ajax
$(document).on('click', '#detail', function(){
var sono = $('#sono').val();
var opnamedate = $('#opnamedate').val();
var wh = $('#warehousecode').val();
var stocktypeid = $('#stocktypeid').val();
alert(sono);
});
you have to make the id also dynamic and also the script sholud be dynamic.Hope you get it
id="detail1"
.on('click', '#detail1', function() ----for first
.on('click', '#detail2', function() ----for second and so on
<form action="<?php echo base_url() ?>index.php/stock_opname/proses_detail" method="post">
<table class="table table-striped">
<thead>
<tr>
<th>No</th>
<th>SO No</th>
<th>Opname Date</th>
<th>Warehouse</th>
<th>Type</th>
<th>Approve</th>
<th>Close period</th>
<th>Detail</th>
</tr>
</thead>
<tbody>
<?php $no=1; foreach ($show as $key) { ?>
<tr>
<td><?php echo $no ?></td>
<td><input type="text" id="sono<?php echo $no; ?>" value="<?php echo $key->sono ?>"></td>
<td><input type="text" id="opnamedate<?php echo $no; ?>" value="<?php echo $key->opnamedate ?>"></td>
<td><input type="text" id="warehousecode<?php echo $no; ?>" value="<?php echo $key->warehousecode ?>"></td>
<td><input type="text" id="stocktypeid<?php echo $no; ?>" value="<?php echo $key->stocktypeid ?>"></td>
<td></td>
<td></td>
<td>Detail</td>
</tr>
<?php $no++;} ?>
</tbody>
</table>
</form>
<script type="text/javascript"> //Ajax Load data from ajax
function getDetails(no){
var sono = $('#sono'+no).val();
var opnamedate = $('#opnamedate'+no).val();
var wh = $('#warehousecode'+no).val();
var stocktypeid = $('#stocktypeid'+no).val();
alert(sono);}
hope this will help
Can you try this ?
$('#detail').click(function(){
var sono = $(this).siblings('#sono').val();
var opnamedate = $(this).siblings('#opnamedate ').val();
var wh = $(this).siblings('#wh').val();
var stocktypeid = $(this).siblings('#stocktypeid ').val();
alert(sono);
});
Related
There have a form in a view page that take data as a multidimensional array.In edit mode that form value is fetching and showing data through a foreach loop.
Now my problem is i'm unable to modify that form data in that foreach loop and send it to database. I gone through some posts about foreach key concept but how do I take modified value here in html and send it to database within this foreach loop?
My code fetching data properly but fail to update data.
Here is my code of view page :
<table class="table table-striped" id="dataTable">
<thead>
<tr>
<th>Subscription</th>
<th>Description</th>
<th>Interval</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if (!empty($invoice_detail)) {
foreach ($invoice_detail as $key => $result) { ?>
<tr>
<td><input type="text" name="invoice[$key][invoice_detail_subs]" id="invoice_detail_subs"
value="<?php echo $result->invoice_detail_subs; ?>"/></td>
<td><input type="text" name="invoice[$key][invoice_detail_desc]" id="invoice_detail_desc"
value="<?php echo $result->invoice_detail_desc; ?>"/></td>
<td><input type="text" name="invoice[$key][invoice_detail_interval]" id="invoice_detail_interval"
value="<?php echo $result->invoice_detail_interval; ?>"/></td>
<td><input type="text" name="invoice[$key][invoice_detail_amount]" id="invoice_detail_amount"
value="<?php echo $result->invoice_detail_amount; ?>"/></td>
<td></td>
</tr>
<?php }
} ?>
</tbody>
</table>
Here it is Update code in in controller :
if ($this->input->post('Submit')) {
$query = $this->db->query(
"SELECT * FROM ".$this->db->dbprefix."invoice_details WHERE invoice_detail_invoie_id ='".$id."' "
);
$fetch = $query->row();
$rows = $query->num_rows();
if ($id) {
$data1 = [
'invoice_detail_subs' => $this->input->post('invoice_detail_subs'),
'invoice_detail_desc' => $this->input->post('invoice_detail_desc'),
'invoice_detail_interval' => $this->input->post('invoice_detail_interval'),
'invoice_detail_amount' => $this->input->post('invoice_detail_amount'),
'invoice_detail_mddt' => date("Y-m-d H:i:s")
];
$this->db->update('invoice_details', $data1, 'invoice_detail_invoie_id = '.$id);
}
}
View Code
<table class="table table-striped" id="dataTable">
<thead>
<tr>
<th>Subscription</th>
<th>Description</th>
<th>Interval</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if (is_object($invoice_detail)) :
foreach ($invoice_detail as $key => $result) : ?>
<tr>
<td><input type="text" name="invoice_detail_subs"
value="<?= $result->invoice_detail_subs; ?>"/></td>
<td><input type="text" name="invoice_detail_desc"
value="<?= $result->invoice_detail_desc; ?>"/></td>
<td><input type="text" name="invoice_detail_interval"
value="<?= $result->invoice_detail_interval; ?>"/></td>
<td><input type="text" name="invoice_detail_amount"
value="<?= $result->invoice_detail_amount; ?>"/></td>
<td></td>
</tr>
<?php endforeach;
endif; ?>
</tbody>
update code in controller
if ($this->input->method()=="post") {
if ($id) {
$data1 = ['invoice_detail_subs'=> $this->input->post('invoice_detail_subs'),
'invoice_detail_desc' => $this->input->post('invoice_detail_desc'),
'invoice_detail_interval' => $this->input->post('invoice_detail_interval'),
'invoice_detail_amount' => $this->input->post('invoice_detail_amount'),
'invoice_detail_mddt' => date("Y-m-d H:i:s")];
$this->db->update($this->db->dbprefix."invoice_details", $data1,['invoice_detail_invoie_id'=>$id]);
}
}
$query = $this->db->select('*')->where(["invoice_detail_invoie_id"=>$id])->get($this->db->dbprefix."invoice_details");
$fetch = $query->row();
$rows = $query->num_rows();
I want to develop while loop form in PHP. I am able to create different name in each row but don't know how to handle POST value in next page.
Below is my code:
<form action="sms.php" method="post" enctype="multipart/form-data">
<table class="table table-hover" style="border: groove;">
<thead>
<tr>
<th>Student Id</th>
<th>Student Name</th>
<th>Phone Number</th>
<th>Today's Attendance</th>
</tr>
</thead>
<tbody>
<?php
$c = 1;?>
<?php
$database = new Database();
$db = $database->getConnection();
$user = new User($db);
$stmt = $user->present();
while($ro1 = $stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<tr>
<td><input name ="uname" id ="uname" style ="border:none;background: none;" value = "<?php echo $ro1['user_id'] ?>" readonly/></td>
<td><?php echo $ro1['first_name'] ?> <?php echo $ro1['last_name'] ?></td>
<td><input name = "list<?php echo $c++ ?>" id ="cont1" type="number" style ="border:none;background: none;" onBlur="checkAvailability1a()" value="<?php echo $ro1['parent_contact'] ?>"/></td>
<td><input id="press1" name="press1" type="button" value="<?php echo $ro1[$_SESSION['dyy']] ?>" onclick="return change(this);" onBlur="checkAvailability()" class="w3-button w3-teal"/></td>
</tr>
<?php } ?>
</tbody>
</table>
<button name="back"><a href = 'attendance.php'>< Back</a></button>
<button type="submit" name="next">Next</a></button>
You don't need to give your input name a counter based on the loop. You can use array notation for your input name, for example:
<?php
$database = new Database();
$db = $database->getConnection();
$user = new User($db);
$stmt = $user->present();
while($ro1 = $stmt->fetch(PDO::FETCH_ASSOC)) {
?>
<tr>
<td><input name ="uname[]" id ="uname" style ="border:none;background: none;" value = "<?php echo $ro1['user_id'] ?>" readonly/></td>
<td><?php echo $ro1['first_name'] ?> <?php echo $ro1['last_name'] ?></td>
<td><input name = "list[]" id ="cont1" type="number" style ="border:none;background: none;" onBlur="checkAvailability1a()" value="<?php echo $ro1['parent_contact'] ?>"/></td>
<td><input id="press1" name="press1[]" type="button" value="<?php echo $ro1[$_SESSION['dyy']] ?>" onclick="return change(this);" onBlur="checkAvailability()" class="w3-button w3-teal"/></td>
</tr>
<?php } ?>
Then in your next page (sms.php) you can get the request parameter with $_POST['list'] (without the [] ). That parameter will be an array in php.
Im trying to fetch records from database, then i have to upload a image which should be stored in folder and also link to be updated in table.. Everything working fine only with last row.. For first row its not updating.. Please help me where im goin on.. Below is my code
<?php
$email1 = $_SESSION['email'];
$Vendor_id = "SELECT Vendor_id FROM vendors where email = '$email1' ";
$result = mysqli_query($conn, $Vendor_id);
$row = mysqli_fetch_row($result);
$sql = "select Vendor_wallet_id, total_amount, request, amount, status, amt_pdflink from vendor_wallet";
$query = mysqli_query($conn, $sql);
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Transfer ID</th>
<th>Request</th>
<th>Amount</th>
<th>Status</th>
<th>Upload</th>
<th>Submit</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($query))
{
$cpid = $row['Vendor_wallet_id'];
$tid = $row['request'];
$type = $row['amount'];
$pays = $row['status'];
$amt = $row['amt_pdflink'];
?>
<tr>
<td value="<?php echo $cpid; ?>" name="cpid"><?php echo $cpid; ?></td>
<td><?php echo $tid; ?></td>
<td><?php echo $type; ?></td>
<td><?php echo $pays; ?></td>
<td><input type="file" value="<?php echo $amt; ?>" name="fileToUpload" id="fileToUpload" ></td>
<td><input type="submit" value="Submit" name="submit" >
</button>
</td> </tr>
<?php } ?>
</tbody>
</table>
</form>
upload.php is taken from https://www.w3schools.com/php/php_file_upload.asp
on your form
<?php
$email1 = $_SESSION['email'];
$Vendor_id = "SELECT Vendor_id FROM vendors where email = '$email1' ";
$result = mysqli_query($conn, $Vendor_id);
$row = mysqli_fetch_row($result);
$sql = "select Vendor_wallet_id, total_amount, request, amount, status, amt_pdflink from vendor_wallet";
$query = mysqli_query($conn, $sql);
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Transfer ID</th>
<th>Request</th>
<th>Amount</th>
<th>Status</th>
<th>Upload</th>
<th>Submit</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($query))
{
$cpid = $row['Vendor_wallet_id'];
$tid = $row['request'];
$type = $row['amount'];
$pays = $row['status'];
$amt = $row['amt_pdflink'];
?>
<tr>
<td value="<?php echo $cpid; ?>" name="cpid"><?php echo $cpid; ?></td>
<td><?php echo $tid; ?></td>
<td><?php echo $type; ?></td>
<td><?php echo $pays; ?></td>
<td><input type="file" name="fileToUpload []" class="fileToUpload" ></td>
<input type="hidden" value="<?php echo $amt; ?>" name="fileToUploadLink []" class="fileToUploadLink" >
<td><input type="submit" value="Submit" name="submit" >
</button>
</td> </tr>
<?php } ?>
</tbody>
</table>
</form>
on upload.php
<?php
if(isset($_FILES['fileToUpload']['tmp_name'])&&isset($_POST['fileToUploadLink'])){
for($i=0;$i<=(count($_FILES['fileToUpload']['tmp_name'])-1);$i++){
move_uploaded_file($_FILES['fileToUpload']['tmp_name'][$i],$_POST['fileToUploadLink'][$i]);
}
}
?>
I have a few suggestions:
In your "php.ini" file, search for the file_uploads directive, and set it to On: file_uploads = On
...</button><!-- <<-- How are you using this? -->
Could try to echo $amt; at the bottom of the loop to see if the path is correct.
May want to check if the $amt with IF Empty condition/statement and maybe check the condition of your other variables.
$email1 = $_SESSION['email'];
$Vendor_id="SELECT Vendor_id FROM vendors where email = '$email1' ";
$result=mysqli_query($conn,$Vendor_id);
$row = mysqli_fetch_row($result);
$sql = "select Vendor_wallet_id, total_amount, request, amount, status, amt_pdflink from vendor_wallet";
$query = mysqli_query($conn, $sql);
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Transfer ID</th>
<th>Request</th>
<th>Amount</th>
<th>Status</th>
<th>Upload</th>
<th>Submit</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($query))
{
$cpid=$row['Vendor_wallet_id'];
$tid=$row['request'];
$type=$row['amount'];
$pays=$row['status'];
$amt=$row['amt_pdflink'];
?>
<tr>
<td value="<?php echo $cpid; ?>" name="cpid"><?php echo $cpid;?></td>
<td><?php echo $tid;?></td>
<td><?php echo $type;?></td>
<td><?php echo $pays;?></td>
<td><input type="file" value="<?php echo $amt;?>" name="fileToUpload" id="fileToUpload" ></td>
<td><input type="submit" value="Submit" name="submit" >
</button> <!-- WHY IS THIS HERE? -->
</td></tr>
<?php
echo $amt; //See if it is correct path
}//END WHILE ?>
</tbody>
</table>
</form>
There are a few ways in which you could do the file upload, one of which would be to make the form a child of a single table cell and have the file field as a direct child of that form. The submit button, to keep the layout, would not be a child of the form and would need to be changed to a simple button input type then use javascript to submit the form
<?php
$email1 = $_SESSION['email'];
$Vendor_id = "SELECT Vendor_id FROM vendors where email = '$email1' ";
$result = mysqli_query($conn, $Vendor_id);
$row = mysqli_fetch_row($result);
$sql = "select Vendor_wallet_id, total_amount, request, amount, status, amt_pdflink from vendor_wallet";
$query = mysqli_query($conn, $sql);
?>
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Transfer ID</th>
<th>Request</th>
<th>Amount</th>
<th>Status</th>
<th>Upload</th>
<th>Submit</th>
</tr>
</thead>
<tbody>
<?php
while( $row = mysqli_fetch_array( $query ) ) {
$cpid = $row['Vendor_wallet_id'];
$tid = $row['request'];
$type = $row['amount'];
$pays = $row['status'];
$amt = $row['amt_pdflink'];
?>
<tr>
<td value="<?php echo $cpid; ?>" name="cpid"><?php echo $cpid; ?></td>
<td><?php echo $tid; ?></td>
<td><?php echo $type; ?></td>
<td><?php echo $pays; ?></td>
<td>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" value="<?php echo $amt; ?>" name="fileToUpload" />
</form>
</td>
<td><input type="button" value="Submit" name="submit" /></td>
</tr>
<?php
}
?>
</tbody>
</table>
<script>
var bttns=Array.prototype.slice.call(document.querySelectorAll('input[type="button"][name="submit"]'));
bttns.forEach(function(bttn){
bttn.addEventListener('click',function(evt){
this.parentNode.parentNode.querySelector('form').submit();
}.bind(bttn),false );
});
</script>
Seems like You want to make a form per row.
<tr>
<td value="<?php echo $cpid; ?>" name="cpid"><?php echo $cpid; ?></td>
<td><?php echo $tid; ?></td>
<td><?php echo $type; ?></td>
<td><?php echo $pays; ?></td>
<td colspan="2">
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="Vendor_wallet_id" value="<?php echo $cpid;?>" />
<input type="file" value="<?php echo $amt; ?>" name="fileToUpload" />
<button>Submit</button>
</form>
</td>
</tr>
</form>
and remove <form> tag that wraps table
I have a problem detecting the error which I'm receiving.
Warning: Invalid argument supplied for foreach()
I'm trying to display an object's entities which are stored using Phpmyadmin. I'm using an MVC architecture.
FormController:
public function run(){
$tabteachers='';
if(!empty($_SESSION['apply']) && !empty($_SESSION['application'])){
$tabteachers = DB::getInstance()->select_teacher_id($_SESSION['login']);
}
require_once(VIEW_PATH.'formdeux.php');
}
Db.class function():
public function select_teacher_id($login){
$query = 'SELECT * FROM teachers,internships,students WHERE teachers.email_teacher = internships.email_responsible_internship AND students.registry_number_student = internships.registry_student_internship AND internships.registry_student_internship = '. $this->_db->quote ( $login );
$result = $this->_db->query ( $query );
if ($result->rowcount () != 0) {
while ( $row = $result->fetch () ) {
$teacher[]= new teacher ( $row->email_teacher,$row->firstname_teacher,$row->lastname_teacher,$row->responsible_internship_teacher,NULL);
}
return $teacher;
}
}
Form View:
<table>
<thead>
<tr>
<th width="20%" class="decoration">contact</th>
</tr>
</thead>
<tbody>
<?php foreach ($tabteachers as $teacher) { ?>
<tr>
<td>Lastname: <td>
<input type="text" name="lastnamepro" value="<?php echo $teacher->lastname_teacher() ?>" size="100px">
</tr>
<tr>
<td>Firstname: <td>
<input type="text" name="firstnamepro" value="<?php echo $teacher->firstname_teacher() ?>" size="100px">
</tr>
<tr>
<td>Email address: <td>
<input type="text" name="emailpro" value="<?php echo $teacher->email_teacher() ?>" size="100px">
</tr>
<tr>
<td>Service: <td>
<input type="text" name="servicepro" value="null" size="100px">
</tr>
<tr>
<td>mobile number: <td>
<input type="text" name="phonenumberpro" value="aucun numero" size="100px">
</tr>
<?php } ?>
</tbody>
</table>
thanks for your help in advance!
How do I insert all employee attendance(Monthly once) in mysql database
Here is my db tables
att_employee_id | att_year | att_month | att_present_days | att_absent_days | att_workingdays
Date.prototype.daysInThisMonthOfThisYear=function() {
return new Date(this.getFullYear(),this.getMonth()+1,0).getDate();
}
var days_inmonth = new Date().daysInThisMonthOfThisYear();
$(document).ready(function() {
$( ".absent_days" ).keyup(function() {
var days = $(this).val();
$(this).closest("tr").find(".present_days" ).val( days_inmonth - days );
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<form name="emp_att" action="" method="post">
<table>
<thead>
<tr>
<th class="head0" style="width:5%">S.No</th>
<th class="head1" style="width:15%">Employee ID</th>
<th class="head0 no-sort" style="width:15%">No.of days present</th>
<th class="head1 no-sort" style="width:15%">No.of days absent</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>ETO0001</td>
<td><input type="text" class="present_days" name="present_days" value=""></td>
<td><input type="number" name="absent_days" class="absent_days" min="0" max="<?php echo date('t'); ?>" onChange="absentdays()" style="width:100%"></td>
</tr>
<tr>
<td>2</td>
<td>ETO0002</td>
<td><input type="text" class="present_days" name="present_days" value=""></td>
<td><input type="number" name="absent_days" class="absent_days" min="0" max="<?php echo date('t'); ?>" onChange="absentdays()" style="width:100%"></td>
</tr>
<tr>
<td>3</td>
<td>ETO0003</td>
<td><input type="text" class="present_days" name="present_days" value=""></td>
<td><input type="number" name="absent_days" class="absent_days" min="0" max="<?php echo date('t'); ?>" onChange="absentdays()" style="width:100%"></td>
</tr>
<tr>
<td>4</td>
<td>ETO0004</td>
<td><input type="text" class="present_days" name="present_days" value="" readonly></td>
<td><input type="number" name="absent_days" class="absent_days" min="0" max="<?php echo date('t'); ?>" onChange="absentdays()" style="width:100%"></td>
</tr>
</tbody>
</table>
<input type="submit" name="submit" value="Submit">
</form>
Here is my query to get all the employees
<form name="emp_att" action="" method="post">
<table>
<thead>
<tr>
<th class="head0" style="width:5%">S.No</th>
<th class="head1" style="width:15%">Employee ID</th>
<th class="head0 no-sort" style="width:15%">No.of days present</th>
<th class="head1 no-sort" style="width:15%">No.of days absent</th>
</tr>
</thead>
<tbody>
<?php
$allemp= mysqli_query($con,"select * from t_emp e");
$all_emp = mysqli_num_rows($allemp);
if ($all_emp > 0)
{
$i=1;
while($all_emp = mysqli_fetch_assoc($allemp))
{
echo "<tr>";
echo "<td>".$i."<input type='hidden' name='serialno' value='".$i++."'></td>
<td> ".$all_emp["emp_id"]."</td>
<td><input type='text' class='present_days' name='present_days' value=''></td>";
echo "<td><input type='number' name='absent_days' class='absent_days' min='0' max= date('t') onChange='absentdays()' style='width:100%'></a></td>";
echo "</tr>";
}
}
else
{
echo "0 Results";
}
?>
</tbody>
</table>
<input type="submit" name="submit" value="Submit">
</form>
Here I am getting all the n number of employees in the above form. when entered all employees "No.of days absent" and then hit on submit I am able to send only last record to the database.
Can any one help me to send all the employees attendance to database
Here is my form submission query
<?php
if(isset($_POST['submit']))
{
$serialno=$_post['serialno'];
$employee_id=$_post['emp_id'];
$att_year = date('Y');
$att_month = date('m');
for($i=1; $i<= $serialno;$i++)
{
$present_days=$_POST['present_days'];
$absent_days=$_POST['absent_days'];
}
$query=mysqli_query($con,"INSERT INTO t_emp_attendance(att_employee_id,att_year,att_month,att_present_days,att_absent_days)values('$employee_id','$att_year','$att_month','$present_days','$absent_days')");
}
?>
any suggestions will be appreciated, I need to store all the employees attendance to database
Check that name of input fields are created. It might be overwritten with the latest values. Send it as an array format like "absent_days[]" it will solve your problem
Check you spelling for INSERT. And also you have missed to pass the connection object for inserting
First parameter should be the connection object in mysqli_*
mysqli_query(connectionObject,your Query);
$query=mysqli_query("INSERT INTO t_emp_attendance(att_employee_id,att_year,att_month,att_present_days,att_absent_days)values('$employee_id','$att_year','$att_month','$present_days','$absent_days')");
for($i=1; $i<= $serialno;$i++)
{
$present_days=$_POST['present_days'][$i];
$absent_days=$_POST['absent_days'][$i];
$query=mysqli_query($con,"INSERT INTO t_emp_attendance(att_employee_id,att_year,att_month,att_present_days,att_absent_days)values('$employee_id','$att_year','$att_month','$present_days','$absent_days')");
}
Your query should be inside the loop. And as suggested by parag, make text field names as arrays []
Soomething like this,
<input type="text" class="present_days" name="present_days[]" value="">
^ ^
You shud do for all the text boxes.