D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
edit_bulk.php
back
Copy
<?php include "../config.php"; ?> <?php // Initialize variables $ids = []; $english_titles = []; $urdu_titles = []; if ($_SERVER["REQUEST_METHOD"] == "POST") { // Handle form submission for updating multiple audio details $ids = $_POST["id"]; $english_titles = $_POST["english_title"]; $urdu_titles = $_POST["urdu_title"]; // Establish a database connection $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Loop through each record and update the audio file details in the database for ($i = 0; $i < count($ids); $i++) { $id = $ids[$i]; $english_title = $english_titles[$i]; $urdu_title = $urdu_titles[$i]; $query = "UPDATE audio_files SET english_title = '$english_title', urdu_title = '$urdu_title' WHERE id = $id"; if ($conn->query($query) !== TRUE) { echo "Error updating record with ID $id: " . $conn->error . "<br>"; } } echo "Records updated successfully."; $conn->close(); } else { // Retrieve all audio file details // Establish a database connection $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Query to select all audio files $query = "SELECT id, english_title, urdu_title FROM audio_files"; $result = $conn->query($query); if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $ids[] = $row["id"]; $english_titles[] = $row["english_title"]; $urdu_titles[] = $row["urdu_title"]; } } else { echo "No audio files found."; } $conn->close(); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bulk Edit Audio Files</title> <link rel="stylesheet" href="css.css"> </head> <body> <header> <div class="logo"><img src="logo.png"></div> </header> <div class="mainbody"> <div class="bodyarea"> <div class="dextop"> <h1>Bulk Edit Audio Files</h1> <form method="post" action="bulk_edit_audio.php"> <table border="1"> <tr> <th>ID</th> <th>Urdu Title</th> <th>English Title</th> </tr> <?php for ($i = 0; $i < count($ids); $i++): ?> <tr> <td> <input type="hidden" name="id[]" value="<?php echo $ids[$i]; ?>"> <?php echo $ids[$i]; ?> </td> <td><input type="text" name="urdu_title[]" value="<?php echo $urdu_titles[$i]; ?>"></td> <td><input type="text" name="english_title[]" value="<?php echo $english_titles[$i]; ?>"></td> </tr> <?php endfor; ?> </table> <input type="submit" value="Update"> </form> </div> </div> </div> <footer> <a href="https://webograph.pk/">Site BY Webograph.pk</a> </footer> </body> </html>