我有一个表单,它有一些输入字段,还有一些复选框字段。如果任何一个填写字段并选择一些复选框然后提交。然后根据提交的一些数据显示在另一个div上。
现在,如果同一个人在首次提交后再次填写该字段,请选中复选框并提交。然后根据提交的一些数据显示在div上。但它取代了旧的提交内容。我需要所有提交内容,包括所有旧的提交内容。
我的代码是:
<form class="reservation-form mb-0" action="" method="post" novalidate autocomplete="off">
<input name="name1" class="form-control required " type="text" placeholder="Enter Name" aria-required="true" required>
<input name="age" class="form-control required " type="number" placeholder="Enter Age" aria-required="true" required>
<select required id="selectarea" class="form-control" name="selectgender">
<option>Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<?php
$query1=mysql_query("select * from lab_location_package_rel where city_id='$selectcity1' AND area_id='$selectarea1' AND lab_id='$selectlab1'") or die (mysql_error());
while($value = mysql_fetch_array($query1)) {
$mrp=$value['mrp'];
$opp=$value['offer_price_perc'];
$package_id=$value['package_id'];
$per=$mrp*$opp/100;
$total=$mrp-$per;
$query2=mysql_query("select * from package_master where id='$package_id'") or die (mysql_error());
$value2 = mysql_fetch_array($query2);
?>
<li class="list-group-item">
<div class="checkbox">
<input type="checkbox" id="checkbox" name="namec[]" value="<?php echo $value["id"]; ?>" />
<label for="checkbox">
<b>Package Name:</b> <?php $package_title1=$value2['package_title']; echo $package_title1;?> <br>
<b>MRP:</b> <strike><?php $mrp1=$value['mrp']; echo $mrp1; ?> </strike><br>
<b>Offer Price:</b> <?php $total1=$total; echo $total1; ?>
</label>
</div>
</li>
<?php }
?>
<input type="submit" class="pull-right btn btn-warning" value="Submit" name="submit">
</form>
现在提交后,显示代码:
<div class="col-md-5">
<h5>Patient Details</h5>
<table class="table table-bordered">
<tbody>
<tr>
<th>Name</th>
<th>Age</th>
<th>Sex</th>
<th></th>
</tr>
<tr>
<?php if(isset($_POST["submit"])==true)
{ ?>
<td><?php echo $_POST['name1']; ?></td>
<td><?php echo $_POST['age']; ?></td>
<td><?php echo $_POST['selectgender']; ?></td>
<td><a href="#" class="btn btn-info">Update</a></td>
<?php } ?>
</tr>
</tbody>
</table>
<br /><br />
<h5>Package Details</h5>
<table class="table table-bordered">
<tbody>
<tr>
<th>Package</th>
<th>MRP</th>
<th>Offer Price</th>
<th></th>
</tr>
<tr>
<?php
extract($_POST);
foreach($_POST['namec'] as $selected){
$query1=mysql_query("select * from lab_location_package_rel where id='$selected'") or die (mysql_error());
while($value = mysql_fetch_array($query1)) {
$mrp=$value['mrp'];
$opp=$value['offer_price_perc'];
$package_id=$value['package_id'];
$per=$mrp*$opp/100;
$total=$mrp-$per;
$query2=mysql_query("select * from package_master where id='$package_id'") or die (mysql_error());
$value2 = mysql_fetch_array($query2);
?>
<tr>
<td><?php echo $value2['package_title']; ?></td>
<td><strike><?php echo $value['mrp']; ?></strike></td>
<td><?php echo $total; ?></td>
<td>Delete</td>
</tr>
<?php
}
}
}
?>
</tr>
</tbody>
</table>
</div>