ok
Direktori : /home/ngwcolle/public_html/LIBRARY-NGWC/admin/ajax/ |
Current File : //home/ngwcolle/public_html/LIBRARY-NGWC/admin/ajax/add_section.php |
<?php // session_start(); //error_reporting(0); // include('../includes/config.php'); include('../includes/dbconnection.php'); // if (strlen($_SESSION['adid']==0)) { // header('location:logout.php'); if(!empty($_POST)) { $output = ''; $cnt=0; $name = $_POST["ename"]; $age=$_POST['eage']; $desc=$_POST['assigndate']; $query = $dbh ->prepare("SELECT * FROM tblsection where classid='$name' and sectioncode='$age'"); $query->execute(); $amountOfRows = $query->rowCount(); if($amountOfRows > 0) { $output .= '<label class="text-danger">Section Already Exist to the Class. <a href="blank.php">Back to Class</a></label>'; // $output .= '<label class="control-label">'.$age.$name.$amountOfRows.'</label>'; } else { $sql="insert into tblsection(classid,sectioncode,strength,vacancy)values(:name,:classdesc,:startdate,:vacancy)"; $query=$dbh->prepare($sql); $query->bindParam(':name',$name); $query->bindParam(':classdesc',$age); $query->bindParam(':startdate',$desc); $query->bindParam(':vacancy',$desc); if($query->execute()) { $output .= '<label class="text-success">Section Added to the Class</label>'; $select = $dbh->prepare("SELECT tc.*,sum(ts.strength)as tot,count(ts.sectioncode) as counts from tblclass tc left join tblsection ts on tc.id=ts.classid GROUP by tc.id order by tc.id asc"); $select->execute(); $output .= ' <table class="table table-bordered table-striped table-vcenter js-dataTable-full-pagination"> <tr> <th class="text-center">ID</th> <th>Class Name</th> <th>Class Code</th> <th>No of Sections</th> <th>Student Strength</th> <th class="d-none d-sm-table-cell">Creation Date</th> <th class="d-none d-sm-table-cell" style="width: 15%;">Action</th></tr>'; while($row=$select->fetch(PDO::FETCH_OBJ)){ $cnt=$cnt+1; $active="Exit"; if(isset($row->status)){ $active="Active"; } $output .='<tr> <td>' . $cnt . '</td> <td>' . $row->classname . '</td> <td>' . $row->classcode . '</td> <td class="d-none d-sm-table-cell"> <span class="badge badge-primary">'.$row->counts.'</span></td> <td class="d-none d-sm-table-cell"> <span class="badge badge-primary">'.$row->tot.'</span></td> <td class="d-none d-sm-table-cell"> <span class="badge badge-primary">'.$row->startdate.'</span></td> "<td><a href="edit.php?id='.$row->id.'" onclick="return confirm(\'Are you sure you want to delete?\');"> <i class="fa fa-trash fa-delete" aria-hidden="true"></i> </a></td> </tr>'; } $output .= '</table>'; } } //validation if ends //insert query execute ends echo $output; } //post if ends ?>