I have a form which consists of rows set up like:
<div class="row unit" onmouseover="this.style.background = '#eeeeee';" onmouseout="this.style.background = 'white';" onclick="if(event.srcElement.nodeName != 'INPUT' && event.srcElement.nodeName != 'SELECT' && event.srcElement.nodeName != 'TEXTAREA'){goToByScroll(event.srcElement,-160);}">
<div class="col">
<div class="select">
<input type="checkbox" id="select<?php echo $i; ?>" name="select<?php echo $i; ?>">
</div>
</div>
<div class="col name">
<p><input class="searchable" type="text" id="name<?php echo $i; ?>" name="name<?php echo $i; ?>" value="<?php echo $name; ?>"></p>
<p>Badge ID: <input class="searchable" type="text" id="badge<?php echo $i; ?>" name="badge<?php echo $i; ?>" value="<?php echo $badge; ?>" style="width: 50px;"></p>
</div>
<div class="col phone">
<p>Work: <input class="searchable" type="text" id="phone<?php echo $i; ?>" name="phone<?php echo $i; ?>" value="<?php echo $phone; ?>"></p>
<p>Cell: <input class="searchable" type="text" id="cell<?php echo $i; ?>" name="cell<?php echo $i; ?>" value="<?php echo $cell; ?>"></p>
<p>Home: <input class="searchable" type="text" id="home<?php echo $i; ?>" name="home<?php echo $i; ?>" value="<?php echo $home; ?>"></p>
</div>
<div class="col email">
<p>Work: <input class="searchable" type="text" id="email<?php echo $i; ?>" name="email<?php echo $i; ?>" value="<?php echo $email; ?>"></p>
<p>Personal: <input class="searchable" type="text" id="perEmail<?php echo $i; ?>" name="perEmail<?php echo $i; ?>" value="<?php echo $perEmail; ?>"></p>
</div>
<div class="col file">
<p class="removeFile"><input type="text" id="filename<?php echo $i; ?>" name="filename<?php echo $i; ?>" class="file" value="<?php echo $filename; ?>" readonly>
Remove: <input type="checkbox" id="removeFile<?php echo $i; ?>" name="removeFile<?php echo $i; ?>"></p>
<input type="file" id="file<?php echo $i; ?>" name="file<?php echo $i; ?>" onchange="myForm.elements['filename<?php echo $i; ?>'].value=myForm.elements['file<?php echo $i; ?>'].value;">
</div>
</div>
These rows get repeated using a javascript function which increments the name:
function addTableRow(table){
for(i=0; i<myForm.elements['entriesNum'].value; i++){
var $tr = $(table).find(".row:last").clone();
$tr.find("input,select,textarea").attr("name", function(){
var parts = this.id.match(/(\D+)(\d+)$/);
return parts[1] + ++parts[2];
}).attr("id", function(){
var parts = this.id.match(/(\D+)(\d+)$/);
return parts[1] + ++parts[2];
});
$(table).find(".row:last").after($tr);
$tr.find('.fileElements').remove();
$tr.find('input[type!="radio"], textarea').removeAttr("value");
$tr.find('input').removeAttr("checked");
$tr.find('select option:first-child').attr("selected", true);
$tr.find('input[type!="radio"]').removeAttr("disabled");
$tr.find('input[type="radio"]').attr("disabled", "disabled");
$tr.find('.error').hide();
}
}
This works perfectly until the number of rows gets higher than 111. At this point when I submit no more data gets included in the array no matter how many rows I add. I was able to deduce this by using print_r($_REQUEST);. I have edited my php.ini and set all the maxes to be absurdly high with still no change.
Whenever I've had issues with javascript created form elements not showing up in the POST, it's always had to do with the way I've structured the FORM tags.
Things to look for...
Is your FORM tag properly closed off?
Is your FORM start and close at the same level in the DOM? For example, you wouldn't want to do this...
<form method='post'>
<div>
<!--lots of stuff-->
</form>
</div>
You would instead want this...
<form method='post'>
<div>
<!--lots of stuff-->
</div>
</form>
Do you have another FORM tag that's opened and not closed before the one you're actually working with? Like this...
<form method='get'>
<!--some kind of form about something else-->
<form method='post'>
<!--the data you're currently focused on-->
</form>
Related
I have a form for submitting students' scores which is supposed to capture the session id (session ids are used to to show the session that a school is currently on e.g 2018/2019 session, 2019/2020 session...)
session table
In the scores table in the database, the session id is automatically captured and inserted. Currently, the session id is 14.
session id
However, for reasons unknown 0s are inserted instead of 14. This is causing so many issues
In the add scores form, scores values are only repopulated if the session id is 14. Now, since it shows 0, the value boxes remain 0
Also I believe it causes duplicate issues. During edits in the form, all scores of students are duplicated.
Controller
function assigngradeAction()
{
for($i=0; $i<count($this->input->post('number')); $i++)
{
$data[]=array(
'section_id' => $this->input->post('section_id'),
'subject_id' => $this->input->post('subject_id'),
'class_id' => $this->input->post('class_id')[$i],
'student_id' => $this->input->post('student_id')[$i],
'session_id' => $this->input->post('session_id'),
'ca1' => $this->input->post('ca1')[$i],
'ca2' => $this->input->post('ca2')[$i],
'ca3' => $this->input->post('ca3')[$i],
'ca4' => $this->input->post('ca4')[$i],
'project' => $this->input->post('project')[$i],
'affective' => $this->input->post('affective')[$i],
'psychomotor' => $this->input->post('psychomotor')[$i],
'exam'=> $this->input->post('exam')[$i],
'tot_score'=> $this->input->post('ca1')[$i] + $this->input->post('ca2')[$i] + $this->input->post('ca3')[$i] + $this->input->post('ca4')[$i] + $this->input->post('project')[$i] + $this->input->post('affective')[$i] + $this->input->post('psychomotor')[$i] + $this->input->post('exam')[$i],
);
}
$inserted = $this->primary_model->add1($data);
if($inserted > 0)
{
$this->session->set_flashdata('msg', '<div class="alert alert-success">Grade Added successfully</div>');
//Echo back success json
redirect('admin/primary/index');
}
}
model
public function add1($data)
{
// for each record insert
foreach($data as $studentScore){
// get score
$subjectId = $studentScore['subject_id'];
$classId = $studentScore['class_id'];
$sessionId = $studentScore['session_id'];
$sectionId = $studentScore['section_id'];
$studentId = $studentScore['student_id'];
$score = $this->get_student_score($subjectId,$sessionId,$sectionId,$classId,$studentId);
$studentScore['modified_at'] = date("Y-m-d H:i:s");
if(empty($score->id)){
$this->db->insert('scores_primary', $studentScore);
}else{
$this->db->where('id', $score->id);
$this->db->update('scores_primary', $studentScore);
}
// var_dump($studentScore, "\n >>>>>>>>", $score);
}
// $this->db->insert_batch('scores_primary', $data);
// var_dump($this->db->error(), $_SERVER['SERVER_ADDR'] );
// $str = $this->db->last_query();
// echo "<pre>";
// print_r($str);
return true;
}
view
<?php }elseif($class_id >= 15 && $class_id <= 17){ ?>
<form action="<?php echo site_url('admin/primary/assigngradeAction') ?>" method="POST" id="formSubjectTeacher">
<?php echo $this->customlib->getCSRF(); ?>
<div class="row">
<div class="col-lg-3">
<input type="hidden" name="class" value="<?php echo $class_id; ?>">
<input type="hidden" name="subject_id" value="<?php echo $subject_id; ?>">
</div>
<div class="col-lg-4">
<h4><strong><?php echo $session_name; ?></strong></h4>
</div>
</div>
<br>
<hr>
<?php foreach($students as $student){ ?>
<div class="row">
<div class="col-lg-3">
<div class="form-group">
<label>Student Name</label>
<input type="hidden" name="number[]" value="">
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
<input type="hidden" name="session_id" value="<?php echo $student->session_id; ?>">
<input type="hidden" name="student_id[]" value="<?php echo $student->student_id; ?>">
<input type="hidden" name="class_id[]" value="<?php echo $class_id; ?>">
<input type="text" value="<?php echo $CI->GetStudentNameWithID($student->student_id); ?>" class="form-control " readonly>
</div>
</div>
<div class="col-lg-1">
<label>ca1 </label>
<input type="hidden" name="session_id" value="<?php echo $sessionID; ?>">
<input type="number" name="ca1[]" min="0" max="10" class="form-control input-sm rounded-0" value="<?php echo $student->scores? $student->scores->ca1: 0; ?>">
</div>
<div class="col-lg-1" id="t2">
<label>ca2</label>
<input type="number" name="ca2[]" min="0" max="10" class="form-control input-sm rounded-0" value="<?php echo $student->scores? $student->scores->ca2: 0; ?>">
</div>
<div class="col-lg-1" id="assg">
<label>ca3</label>
<input type="number" name="ca3[]" min="0" max="10" class="form-control input-sm rounded-0" value="<?php echo $student->scores? $student->scores->ca3: 0; ?>">
</div>
<div class="col-lg-1" id="exam">
<label>Exam</label>
<input type="number" name="exam[]" min="0" max="70" class="form-control input-sm rounded-0" value="<?php echo $student->scores? $student->scores->exam: 0; ?>">
</div>
<div class="col-lg-1">
<label>Total</label>
<output class="result"></output>
</div>
</div>
<?php } ?>
in your view in form you have two input fields named session_id ↓↓
<input type="hidden" name="session_id" value="<?php echo $student->session_id; ?>">
<input type="hidden" name="session_id" value="<?php echo $sessionID; ?>">
Duplicate fields can cause issues, check which one has the correct
value in it and discard the other one. If both of the fields have
wrong values then check where the values are being initialized and so
on. This is how you debug in PHP.
I need help for this conversion of HTML to PHP
This is my code and I want to write inside the if tag with echo to get the results of the base of conditions for more info I am getting the error around the value of the input field from the database.
<td>
<input type="text" name="sale_rate[]" onchange="getProductData(<?php echo $x; ?>)" id="sale_rate_<?php echo $x; ?>" class="form-control" autocomplete="off" value="<?php echo $val['sale_rate'] ?>">
<input type="hidden" name="sale_rate_value[]" id="sale_rate_value_<?php echo $x; ?>" class="form-control" autocomplete="off">
</td>
to like this
<?php if($user_id == 1)
echo "<td><input type="text" name="sale_rate[]" onchange="getProductData(<?php echo $x; ?>)" id="sale_rate_<?php echo $x; ?>" class="form-control" autocomplete="off" value="<?php echo $val['sale_rate'] ?>">
<input type="hidden" name="sale_rate_value[]" id="sale_rate_value_<?php echo $x; ?>" class="form-control" autocomplete="off">
</td>";
?>
Any kindly of help will be so appreciated
You can close and reopen <?php ?> tags. So you don't need echo
<?php if($user_id == 1){ ?>
<td>
<input type="text" name="sale_rate[]" onchange="getProductData(<?php echo $x; ?>)" id="sale_rate_<?php echo $x; ?>" class="form-control" autocomplete="off" value="<?php echo $val['sale_rate'] ?>">
<input type="hidden" name="sale_rate_value[]" id="sale_rate_value_<?php echo $x; ?>" class="form-control" autocomplete="off">
</td>
<?php } ?>
Alternatively, you can use if/endif syntax:
<?php if($statement): ?>
<some-html>...</some-html>
<?php endif; ?>
There are many different approaches, which amount to as much a matter of style as anything else.
Personally, I prefer to not have numerous instances of <?php [CODE HERE] ?> throughout my markup, so, instead, I would favour something more like this:
<?php
if($user_id == 1) {
echo '
<td>
<input type="text" name="sale_rate[]" onchange="getProductData('.$x.')" id="sale_rate_'.$x.'" class="form-control" autocomplete="off" value="'.$val['sale_rate'].'">
<input type="hidden" name="sale_rate_value[]" id="sale_rate_value_'.$x.'" class="form-control" autocomplete="off">
</td>
';
}
?>
I am trying to store the values obtained from the form into the database. I am stuck where I do not know how to obtain the values individually from foreach($questions as $row) and store them into the database.
My database table has the following columns:
variantid | stepid | questionid | newquestion | radiovalues | description
When I click on save, I am trying to save all the details obtained from the view into the database. every value obtained with each loop of foreach($questions as $row) needs to get stored in a new row. I think I should be using insert_batch, but I do not know how I can put all the data into the array.
How can I proceed with this? The following is the code that I have written. I have not written anything in model as I am stuck.
<form id="theform">
<label for="variants">Variants:</label><br>
<?php
foreach($variants as $row)
{?>
<div class="form-group">
<input type="radio" name="variants[]" checked="true" id="variants" value="<?php echo $row->variantid ?>"/><?php echo $row->variantname ?><br/>
<?php }
?>
<div id='steplist'>
<?php
foreach($substeps as $row){
?>
<div id='img_div'>
<input type="radio" name="stepid[]" checked="true" id="stepid<?php echo $row->stepid; ?>" value="<?php echo $row->stepid; ?>"/><?php echo $row->stepname ?><br/>
</div>
<?php
foreach($questions as $each){
?><br><br>
<input type="text" name="questions[]" id="questions<?php echo $each->questionid; ?>" value="<?php echo $each->questionname; ?>" readonly/><br/>
<input type="hidden" name="questionid[]" id="questions<?php echo $each->questionid; ?>" value="<?php echo $each->questionid; ?>"/>
<a id="addq">Add question</a>
<input type="text" class="form-control" name="newquestion[]" style="font-weight:bold;width:100%;height:5%" id="new_questions<?php echo $each->questionid; ?>" /><br>
<div class="radio" id="answer">
<label style="font-weight:bold"><input type="radio" name="radioquestions[<?php echo $each->questionid; ?>][optradio]" value="no" required>no</label>
<label style="font-weight:bold"><input type="radio" name="radioquestions[<?php echo $each->questionid; ?>][optradio]" value="probably no" required>probably no </label>
<label style="font-weight:bold"><input type="radio" name="radioquestions[<?php echo $each->questionid; ?>][optradio]" value="unknown" required>unknown</label>
<label style="font-weight:bold"><input type="radio" name="radioquestions[<?php echo $each->questionid; ?>][optradio]" value="probably yes" required>probably yes</label>
<label style="font-weight:bold"><input type="radio" name="radioquestions[<?php echo $each->questionid; ?>][optradio]" value="yes">yes</label>
</div>
<textarea name="question1_text[]" id="description<?php echo $each->questionid; ?>" rows="3" cols="73"></textarea><br>
<?php
}
?>
<?php
}
?>
</div>
</form>
<input type='button' value='Save' class='save' id='save' />
<script>
$(document).ready(function(){
$("#save").click(function(e){
e.preventDefault();
$.ajax({
type:"POST",
url:"<?= base_url() ?>index.php/task/perform",
data:$('#theform').serialize(),
success:function(response){
alert(response);
}
});
});
});
This is my controller:
public function perform(){
var_dump($_POST);
$variantid = $this->input->post('variants');
$stepid = $this->input->post('stepid');
$questionid = $this->input->post('questions');
$newquestion = $this->input->post('newquestion');
$radioquestions = $this->input->post('radioquestions');
$question1_text = $this->input->post('question1_text');
$this->load->model('task_model');
$result= $this->task_model->performdata();
if($result){
echo "Data saved successfully";
}
}
Update
Thank you for the quick reply. I changed the code according to the suggestion. How can I get these values into the controller and send them into the database?
The HTML inside the foreach is invalid as it is missing a closing div tag and your input does not have the correct name attribute, for multiple inputs you should use variants[] and not the same ID. Do it in this manner:
<?php foreach ($variants as $row) { ?>
<div class="form-group">
<input type="radio" name="variants[]" checked="true" class="variants" value="<?php echo $row->variantid ?>"/><?php echo $row->variantname ?><br/>
</div>
<?php } ?>
I have a site where the user registers and logs in and then is taken to a page to enter data.
I have successfully been able to recall all the fields in the database as input values into my form and I want to be able to update these values with a save button before submitting.
I have two form buttons providing different actions based on javascript.
I don't receive any errors but when I hit the save button no entries submit to my database.
I am pulling the unique key (email address) from the database and am trying to update all of the fields associated with the row the unique email address is in. I have this field as a hidden input that gets added to the submission when the save button is clicked.
Ive tried REPLACE, ON DUPLICATE KEY UPDATE to update the entry but it still does nothing. Here is my code:
<div style="float:left; width:450px;">
<form id="parts" class="form" name="parts" method="post" ><br>
<input type="hidden" id="email" name="email" value="<? echo $_SESSION['MM_Username']; ?>">
<input type="hidden" id="first_name" name="first_name" value="<? echo $user['first_name']; ?>">
<input type="hidden" id="last_name" name="last_name" value="<? echo $user['last_name']; ?>">
<input type="hidden" id="business_name" name="business_name" value="<? echo $user['business_name']; ?>">
<input type="hidden" id="occupation" name="occupation" value="<? echo $user['occupation']; ?>">
<input type="hidden" id="business_address_1" name="business_address_1" value="<? echo $user['business_address_1']; ?>">
<input type="hidden" id="business_address_2" name="business_address_2" value="<? echo $user['business_address_2']; ?>">
<input type="hidden" id="country" name="country" value="<? echo $user['country']; ?>">
<input type="hidden" id="city" name="city" value="<? echo $user['city']; ?>">
<input type="hidden" id="state_province" name="state_province" value="<? echo $user['state_province']; ?>">
<input type="hidden" id="zip" name="zip" value="<? echo $user['zip']; ?>">
<input type="hidden" id="phone" name="phone" value="<? echo $user['phone']; ?>">
<input type="hidden" id="special_offers" name="special_offers" value="<? echo $user['special_offers']; ?>">
<div id="div1"> </div>
<div id="div2">SET PART #</div>
<div id="div3">INSTALL DATE</div>
<div id="div1">1.</div>
<div id="div2"><input type="text" id="part_1" name="part_1" value="<? echo $user['part_1']; ?>"> </div>
<div id="div3"><input type="text" id="part_1_install_date" name="part_1_install_date" value="<? echo $user['part_1_install_date']; ?>"> </div>
<div id="div1">2.</div>
<div id="div2"><input type="text" id="part_2" name="part_2" value="<? echo $user['part_2']; ?>"></div>
<div id="div3"><input type="text" id="part_2_install_date" name="part_2_install_date" value="<? echo $user['part_2_install_date']; ?>"></div>
<div id="div1">3.</div>
<div id="div2"><input type="text" id="part_3" name="part_3" value="<? echo $user['part_3']; ?>"></div>
<div id="div3"><input type="text" id="part_3_install_date" name="part_3_install_date" value="<? echo $user['part_3_install_date']; ?>"></div>
<div id="div1">4.</div>
<div id="div2"><input type="text" id="part_4" name="part_4" value="<? echo $user['part_4']; ?>"></div>
<div id="div3"><input type="text" id="part_4_install_date" name="part_4_install_date" value="<? echo $user['part_4_install_date']; ?>"></div>
<div id="div1">5.</div>
<div id="div2"><input type="text" id="part_5" name="part_5" value="<? echo $user['part_5']; ?>"></div>
<div id="div3"><input type="text" id="part_5_install_date" name="part_5_install_date" value="<? echo $user['part_5_install_date']; ?>"></div>
<div id="div1">6.</div>
<div id="div2"><input type="text" id="part_6" name="part_6" value="<? echo $user['part_6']; ?>"></div>
<div id="div3"><input type="text" id="part_6_install_date" name="part_6_install_date" value="<? echo $user['part_6_install_date']; ?>"></div>
<div id="div1">7.</div>
<div id="div2"><input type="text" id="part_7" name="part_7" value="<? echo $user['part_7']; ?>"></div>
<div id="div3"><input type="text" id="part_7_install_date" name="part_7_install_date" value="<? echo $user['part_7_install_date']; ?>"></div>
<div id="div1">8.</div>
<div id="div2"><input type="text" id="part_8" name="part_8" value="<? echo $user['part_8']; ?>"></div>
<div id="div3"><input type="text" id="part_8_install_date" name="part_8_install_date" value="<? echo $user['part_8_install_date']; ?>"></div>
<div id="div1">9.</div>
<div id="div2"><input type="text" id="part_9" name="part_9" value="<? echo $user['part_9']; ?>"></div>
<div id="div3"><input type="text" id="part_9_install_date" name="part_9_install_date" value="<? echo $user['part_9_install_date']; ?>"></div>
<div id="div1">10.</div>
<div id="div2"><input type="text" id="part_10" name="part_10" value="<? echo $user['part_10']; ?>"></div>
<div id="div3"><input type="text" id="part_10_install_date" name="part_10_install_date" value="<? echo $user['part_10_install_date']; ?>"></div>
<div id="div1"> </div>
<div id="div2"><input type="submit" name="save" value="Save" onclick="submitForm('save.php')"></div>
<div id="div3"><input class="send" id="register" type="submit" value="Submit" onclick="submitForm('submit.php')" disabled="disabled"></div>
</form>
LOGOUT
</div>
Here is my save button onclick action:
<?php
include("includes/connection.php");
$sql = "INSERT INTO login (email, first_name, last_name, business_name, occupation, business_address_1, business_address_2, country, city, state_province, zip, phone, special_offers, part_1, part_1_install_date, part_2, part_2_install_date, part_3, part_3_install_date, part_4, part_4_install_date, part_5, part_5_install_date, part_6, part_6_install_date, part_7, part_7_install_date, part_8, part_8_install_date, part_9, part_9_install_date, part_10, part_10_install_date)
VALUES ('$_POST[email]','$_POST[first_name]','$_POST[last_name]','$_POST[business_name]','$_POST[occupation]','$_POST[business_address_1]','$_POST[business_address_2]','$_POST[country]','$_POST[city]','$_POST[state_province]','$_POST[zip]','$_POST[phone]','$_POST[special_offers]','$_POST[part_1]', '$_POST[part_1_install_date]', '$_POST[part_2]', '$_POST[part_2_install_date]', '$_POST[part_3]', '$_POST[part_3_install_date]', '$_POST[part_4]', '$_POST[part_4_install_date]', '$_POST[part_5]', '$_POST[part_5_install_date]', '$_POST[part_6]', '$_POST[part_6_install_date]', '$_POST[part_7]', '$_POST[part_7_install_date]', '$_POST[part_8]', '$_POST[part_8_install_date]', '$_POST[part_9]', '$_POST[part_9_install_date]', '$_POST[part_10]', '$_POST[part_10_install_date]')
ON DUPLICATE KEY UPDATE login SET column = 'email' WHERE column='$_POST[email]'";
if (mysqli_query($connection, $sql)) {
echo header('Location: login-ENG.php');
} else {
echo mysqli_error($connection);
}
mysqli_close($connection);
?>
Here is the javascript to differentiate button functions:
<script>
function submitForm(action)
{
document.getElementById('parts').action = action;
document.getElementById('parts').submit();
}
</script>
NONE of your form fields have name attributes. Without name=..., there's nothing to submit. id attributes are not relevant at all for form submission. A simple var_dump($_POST) would have shown you this.
<input type="text" name="email" ... />
^^^^^^^^^^^^
|
VALUES ('$_POST[email]','$
As well, you are vulnerable to sql injection attacks
I have the following code which loops through an array to create forms that are filled with values (which the user will be able to edit) on a single page. There are as many forms as there are loops in the array, which is always changing.
<body>
<div id="main">
<?php
foreach($articles as $item) { ?>
<div id='container'>
<form>
Title: <input type="text" name="title" size="80" value="<?php echo $item[0]; ?>">
<br>
URL: <input type="text" name="url" size="80" value="<?php echo $item[1]; ?>">
<br>
End Date: <input type="text" name="endDate" value="<?php echo substr($item[7], 14, strpos($item[7], '#') - strlen($item[7])); ?>">
<br>
<?php
if (substr($item[8], 0, 2) === 'Su'){
} else {
?>
Start Date: <input type="text" name="startDate" value="<?php echo substr($item[8], 7, 9); ?>">
<?php } ?>
</form>
</div>
<?php } ?>
</div>
</body>
Now, I want the user to have a single submit button at the bottom of the page which will submit ALL the forms on the page to MySQL database. The problem is I don't know how to do that.
I know the submit button takes the format of
<input type="submit" value="Submit">
I am assuming I need to give each form in the loop a unique name but from there I am at a loss as to what my next step should be to actually send and receive the information from these multiple forms.
Any help would be appreciated. Thanks.
You can't submit more than one form at once. What is wrong with putting all sets of <input>s into a single form?:
<body>
<div id="main">
<form>
<?php
$inpCnt = 0;
foreach($articles as $item) {
$inpCnt++; ?>
<div id='container'>
Title: <input type="text" name="title_<?php echo $inpCnt; ?>" size="80" value="<?php echo $item[0]; ?>">
<br>
URL: <input type="text" name="url_<?php echo $inpCnt; ?>" size="80" value="<?php echo $item[1]; ?>">
<br>
End Date: <input type="text" name="endDate_<?php echo $inpCnt; ?>" value="<?php echo substr($item[7], 14, strpos($item[7], '#') - strlen($item[7])); ?>">
<br>
<?php
if (substr($item[8], 0, 2) === 'Su'){
} else {
?>
Start Date: <input type="text" name="startDate_<?php echo $inpCnt; ?>" value="<?php echo substr($item[8], 7, 9); ?>">
<?php } ?>
</div>
<?php } ?>
</form>
</div>
</body>
You need to be able to define each of these inputs aswel. So I've used the loop to give each one a unique name.