D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
realadss
/
kavyaeventz.in
/
admin
/
Filename :
faqs-form.php
back
Copy
<?php include('include/header.php'); ?> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <div class="container-full"> <!-- Content Header (Page header) --> <div class="content-header"> <div class="d-flex align-items-center"> <div class="me-auto"> <h4 class="page-title">Add Blog</h4> </div> </div> </div> <!-- Main content --> <div class="row"> <div class="col-xl-12 dash-xl-100"> <div class="card "> <div class="card-body"> <?php $id = $_GET['eid']; $sql1 = "select * from faqs where id = '$id'"; $query1 = mysqli_query($conn, $sql1); $row1 = mysqli_fetch_array($query1); ?> <div class="theme-form mega-form" > <div class="row"> <div class="col-6"> <div class="mb-3"> <label class="col-form-label">Service Category</label> <select class="form-control" id="category" onchange="getsubcatfun()"> <option>--- Select category ---</option> <?php $cat_serv_sql = mysqli_query($conn, "select * from service_cat"); while($cat_serv_data = mysqli_fetch_array($cat_serv_sql)){ $name_cat = $cat_serv_data['name']; ?> <option <?php echo ($row1['category'] == $name_cat) ? "selected": ""; ?>><?= $name_cat;?></option> <?php } ?> <option>Home</option> </select> </div> </div> <div class="col-6"> <div class="mb-3"> <label class="col-form-label">Sub Category</label> <select class="form-control" id="sub_category"> <option>--- Select Sub ---</option> </select> </div> </div> <div class="col-12"> <div class="mb-3"> <label class="col-form-label">Question</label> <input class="form-control" type="text" value="<?= $row1['question'];?>" id="pname"> <input class="form-control" type="hidden" value="<?= $id;?>" id="id"> </div> </div> </div> <div class="mb-3"> <label class="col-form-label">Answer</label> <div id="editor1"><?= html_entity_decode($row1['answer']);?></div> </div> <div class="card-footer"> <?php if($id == ""){ ?> <input type="Submit" value="Submit" id="Submit" class="btn btn-primary"> <?php }else{ ?> <input type="Submit" value="Update" id="update" class="btn btn-primary"> <?php } ?> </div> </div> </div> </div> </div> </div> <!-- /.content --> </div> </div> <!-- /.content-wrapper --> <?php include('include/footer.php') ?> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script src="https://cdn.ckeditor.com/ckeditor5/40.0.0/classic/ckeditor.js"></script> <script> function getsubcatfun(){ var category = $('#category').val(); $.ajax({ url:'ajax/getsubcat.php', type:'POST', data:{category}, success: function(resp) { var data = JSON.parse(resp); document.querySelector('#sub_category').innerHTML = ""; var arr = []; for (var x = 0; x < data.length; x++) { var putdata = []; putdata.push(data[x].pname); putdata.push(data[x].pname); arr.push(putdata); } var placeholder = document.querySelector('#sub_category'); var stru = ""; for (var i = 0; i < arr.length; i++){ stru += ` <div class="col-sm-6"> <option value="${arr[i][1]}" class="form-control">${arr[i][1]}</option> </div> ` } placeholder.innerHTML = stru; } }) } </script> <script> let editor1; ClassicEditor .create( document.querySelector( '#editor1' ) ) .then( newEditor => { editor1 = newEditor; } ) .catch( error => { console.error( error ); } ); $(document).ready(function(){ $("#Submit").click(function(){ var pname = $("#pname").val(); var category = $("#category").val(); var sub_category = $("#sub_category").val(); const editordata1 = editor1.getData(); var fd = new FormData(); fd.append("pname", pname); fd.append("category", category); fd.append("sub_category", sub_category); fd.append("editordata1", editordata1); $.ajax({ url:"ajax/faqs-insert.php", type:"POST", data:fd, dataType: 'json', contentType: false, processData: false, success:function(resp){ if(resp == 1){ alert('Good Job !'); location.reload(); }else{ alert('something Went Wrong!'); } } }) }); $("#update").click(function(){ var id = $("#id").val(); var pname = $("#pname").val(); var category = $("#category").val(); var sub_category = $("#sub_category").val(); const editordata1 = editor1.getData(); var fd = new FormData(); fd.append("id", id); fd.append("pname", pname); fd.append("category", category); fd.append("sub_category", sub_category); fd.append("editordata1", editordata1); $.ajax({ url:"ajax/faqs-update.php", type:"POST", data:fd, dataType: 'json', contentType: false, processData: false, success:function(resp){ if(resp == 1){ alert('Good Job !'); window.location.href="faqs.php"; }else{ alert('something Went Wrong!'); } } }) }); }); </script>