I am a newbee to PHP.
I am trying to develop a website which tracks the daily efforts of a team. The problem is I am stuck with the code at one point.
When I click on Add Event, the fields pop up keeping the values in the typing field as such and resetting the drop down values. Please help in resolving this.
<?php
echo('
<form action="" method="POST">');
$count = isset($_POST['count']) ? $_POST['count'] : 1;
if($count > 11) $count = 11;
?>
<table>
<input type="hidden" name="count" value="<?php echo $count+1; ?>"/>
<?php for($i = 0; $i < $count; $i++):
$val0 = isset($_POST['event'][$i]['0']) ? $_POST['event'][$i]['0'] : '';
$val1 = isset($_POST['field'][$i]['1']) ? $_POST['field'][$i]['1'] : '';
?>
<td><select name="event[<?php echo $i; ?>][1]" value="<?php echo $val1; ?>"/>
<option>Choose Event</option>
<option> Incident </option>
<option> Change </option>
<option> Complaint </option>
<option> Compliance </option>
<option> Transition </option>
<option> Appreciation </option>
<option> Disaster_Recovery </option></td>
<td><input name="field[<?php echo $i; ?>][1]" value="<?php echo $val1; ?>"/></td>
<?php endfor; ?>
</table>
<input type="submit" value="Add Event" />
This is just a sample, I need to add another drop down for each option listed above and also about 20 free text fields for the users to enter their data.
After all these are done, at one shot all these fields should go to the mysql table to their respective columns on submit.
Seems like, I am stuck up very badly. I got to complete this asap. Please help. - Thank you.