Server IP : 51.89.169.208 / Your IP : 18.219.218.77 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/yellowleaf/public_html/staff/locations/ |
Upload File : |
<?php $path = $_SERVER["DOCUMENT_ROOT"]; include_once $path."/connect_db.php"; include '../accesscontrol.php'; if (isset($_POST["submitedit"])) { $meta_title = addslashes(trim($_POST["meta_title"])); $meta_description = addslashes(trim($_POST["meta_description"])); $page_title = addslashes(trim($_POST["page_title"])); $pagetext = addslashes(trim($_POST["pagetext"])); $area_parent_name = addslashes(trim($_POST["area_parent_name"])); $update = $connect->query("UPDATE `locations` SET `meta_title` = '$meta_title', `meta_description` = '$meta_description',`page_title` = '$page_title', `page_text` = '$pagetext' WHERE `area_parent_name` = '$area_parent_name'"); if ($update) { header("location: ./?submit=true"); }else{ header("location: ./?submit=false"); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Yellowdev :: locations</title> <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap5.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.2.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap5.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"> <link rel="stylesheet" href="../header-footer/global.css"> <link rel="stylesheet" href="../style_staff.css"> </head> <body> <?php include '../staff_header.php'; ?> <div class="container mt-5 mb-5"> <div class="card"> <div class="card-body"> <?php if (isset($_GET["submit"])) { if ($_GET["submit"] == "true") { echo "<h5 style='color: green;'>Successfully edited</h5>"; }else{ echo "<h5 style='color: red;'>Failed to edit</h5>"; } } ?> <table id="example" class="table table-striped" style="width:100%"> <thead> <tr> <th>Area Id</th> <th>Location name</th> <th>Description</th> <th>Option</th> </tr> </thead> <tbody> <?php $res_ads = $connect->query("SELECT * FROM ads WHERE active='1' GROUP BY county_name ORDER BY `county_name` ASC"); while ($row_ads = $res_ads->fetch_array(MYSQLI_ASSOC)) { //SELECT * FROM `locations` WHERE `area_parent_name` = 'Aberdeen City' GROUP BY `area_parent_name` $area_name = $row_ads["county_name"]; $res_locations = $connect->query("SELECT * FROM `locations` WHERE `area_parent_name` = '{$area_name}' GROUP BY `area_parent_name` LIMIT 1"); while ($row_location = $res_locations->fetch_array(MYSQLI_ASSOC)) { ?> <tr> <td><?php echo $row_location["area_id"] ?></td> <td><?php echo $row_location["area_parent_name"] ?></td> <td><?php echo $row_location["meta_description"] ?></td> <td><button type="button" id="<?php echo $row_location["area_id"] ?>" class="btn btn-primary btn-sm editarea" data-bs-toggle="modal" data-bs-target="#editmodal">Edit</button></td> </tr> <?php } } ?> </table> </div> </div> <!-- Modal --> <div class="modal fade" id="editmodal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Edit location</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body" id="modalContent"> </div> </div> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.min.js" integrity="sha384-IDwe1+LCz02ROU9k972gdyvl+AESN10+x7tBKgc9I5HFtuNz0wWnPclzo6p9vxnk" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script> <script> $(document).ready(function () { // $('#example').DataTable(); $(".editarea").click("click", function(){ console.log("yes") let id = $(this).attr("id"); $.ajax({ type: "GET", url: "./ajax/load_modal.php", data: {area_id: id}, beforeSend: function () { $("#modalContent").html("<h3 class='text-center'>Loading data..</h1>") }, success: function (response) { $("#modalContent").html(response) } }); }); }); </script> </body> </html>