HTML5 Form with JQuery Repeater, Bootstrap and Multi-Dimensional Array
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
$sql1 = "INSERT INTO clbmeetings (`clbid`, `meeting_date`, `speaker`, `subject`, `attendance_percent`, `ri_year`, `created_by`, `ip`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$stmt1 = mysqli_prepare($conn, $sql1);
if($stmt1){
mysqli_stmt_bind_param($stmt1, "ssssssss", $param_clbid, $param_meeting_date, $param_speaker, $param_subject, $param_attendance_percent, $param_ri_year, $param_created_by, $param_ip);
//Set These Parameters
foreach ($_POST['meet'] as $item) {
if(empty($item['mtdt'])){
echo 'Empty Array';
}
else{
$meeting_date = $item['mtdt'];
$speaker = $item['speaker'];
$subject = $item['subject'];
$attendance_percent = $item['atpercent'];
$param_meeting_date= $meeting_date;
$param_speaker= $speaker;
$param_subject= $subject;
$param_attendance_percent= $attendance_percent;
//Try to execute the Query
if (mysqli_stmt_execute($stmt1)){
$success = " added Successfully!";
}
else{
$err = "Meetings not Updated";
}
}
}
}
else{
$err = "Club Meetings Not Added Sussessfully!";
}
mysqli_stmt_close($stmt1);
}
?>
Form with post Function
<h3>Club Meetings & Nature Of Publication</h3>
<form id="form-horizontal" class="form-horizontal form-wizard-wrapper form-material mb-0" enctype="multipart/form-data" id="add-mreport" role="form" method="POST" action="">
<fieldset>
<h4 class="mt-0 header-title">Club Meetings</h4>
<div class="repeater-default">
<div data-repeater-list="meet">
<div data-repeater-item="">
<!--data goes Here-->
<div class="form-group row d-flex align-items-end text-right">
<div class="col-md-3">
<label for="example-number-input" class="col-form-label text-right">Date of Meeting</label>
<input class="form-control" type="date" name="mtdt" value="" id="mtdt">
</div>
<div class="col-md-3">
<label for="example-number-input" class="col-form-label text-right">Name of Speaker</label>
<input class="form-control" type="text" name="speaker" value="" id="speaker">
</div>
<div class="col-md-3">
<label for="example-number-input" class="col-form-label text-right">Subject</label>
<input class="form-control" type="text" name="subject" value="" id="subject">
</div>
<div class="col-md-2">
<label for="example-number-input" class="col-form-label text-right">% of Attendance</label>
<input class="form-control" type="text" name="atpercent" value="" id="atpercent">
</div>
<div class="col-sm-1">
<span data-repeater-delete="" class="btn btn-danger btn-sm">
<span class="far fa-trash-alt mr-1"></span>
</span>
</div><!--end col-->
</div><!--end row-->
</div><!--end /div-->
</div><!--end repet-list-->
<div class="form-group mb-0 row text-right">
<div class="col-sm-12">
<span data-repeater-create="" class="btn btn-secondary">
<span class="fas fa-plus"></span> Add
</span>
</div><!--end col-->
</div><!--end row-->
</div> <!--end repeter-->
</fieldset>
<!--end fieldset-->
</form>
<!--end form-->
CDN URLs for Required Files
https://cdnjs.cloudflare.com/ajax/libs/jquery.repeater/1.2.1/jquery.repeater.js
https://cdnjs.cloudflare.com/ajax/libs/jquery.repeater/1.2.1/jquery.repeater.min.js
CDN URLs for Required Files
https://cdnjs.cloudflare.com/ajax/libs/jquery.repeater/1.2.1/jquery.repeater.js
https://cdnjs.cloudflare.com/ajax/libs/jquery.repeater/1.2.1/jquery.repeater.min.js
Comments
Post a Comment