D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
u935876328
/
domains
/
ggcp.org.in
/
public_html
/
admin
/
Filename :
eventPhotos.php
back
Copy
<?php include('config.php'); include('header.php'); $msg = ""; $homeFile = "upload/event/"; $event_id = $_POST['event_id']; $arr_homeImages = []; $imageSql = "SELECT * FROM event_images WHERE event_id ='$event_id' order by id DESC"; $homeImagesSql = mysqli_query($db, $imageSql); $arr_homeImages = $homeImagesSql->fetch_all(MYSQLI_ASSOC); $sql = "SELECT * FROM event_tbl WHERE id='$event_id'"; $result = mysqli_query($db, $sql); $arr_event = $result->fetch_all(MYSQLI_ASSOC); if (isset($_POST['uploadImage'])) { $filename = $_FILES["uploadfile"]["name"]; $tempname = $_FILES["uploadfile"]["tmp_name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $newfilename = date('dmYHis') . "." . $ext; $folder = "upload/event/" . $newfilename; mysqli_query($db, "INSERT INTO event_images (filename,event_id) VALUES (\"$newfilename\", \"$event_id\")"); // Now let's move the uploaded image into the folder: image if (move_uploaded_file($tempname, $folder)) { $msg = "Image uploaded successfully"; } else { $msg = "Failed to upload image"; } $homeImagesSql = mysqli_query($db, $imageSql); $arr_homeImages = $homeImagesSql->fetch_all(MYSQLI_ASSOC); } if(isset($_POST['imageDelete'])){ $id = $_POST['delete']; $sql = "DELETE FROM event_images WHERE id='$id'"; $result = $db->query($sql); $homeImagesSql = mysqli_query($db, $imageSql); $arr_homeImages = $homeImagesSql->fetch_all(MYSQLI_ASSOC); } ?> <!DOCTYPE html> <html> <script> function setIsBanner(id, eventId){ $.ajax({ url: 'setBanner.php', type: "POST", data : { id: id, eventId: eventId }, success: function (data) { } }); } </script> <body> <!-- End Navbar --> <div class="content"> <div class="container-fluid"> <h2>Event Photos</h2> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header card-header-primary" style="background: #71774b;"> <h4 class="card-title"><?php echo $arr_event[0]['event_name']?></h4> <p class="card-category">Add Or Delete Photos !!!</p> </div> <div class="card-body"> <div class="row"> <div class="col-md-5 col-sm-12 col-xs-12"> <form method="POST" action="" enctype="multipart/form-data"> <input type="hidden" name="event_id" value="<?php echo $event_id ?>"> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <input type="file" name="uploadfile" value="" required/> </div> <div class="col-md-12 col-sm-12 col-xs-12"> <button type="submit" name="uploadImage" class="btn btn-primary btn-sm btn-block waves-effect text-center m-b-20">UPLOAD</button> </div> </div> </form> </div> <div class="col-md-7 col-sm-12 col-xs-12"> <table class="table table-bordered"> <tr> <th>Image</th> <th>isBanner</th> <th>Action</th> </tr> <?php foreach ($arr_homeImages as $column) { ?> <tr> <td><img src="upload/event/<?php echo $column['filename'] ?>" height="50px" width="80px"></td> <td><input type="radio" id="isBanner" name="isBanner" onclick="setIsBanner(<?php echo $column['id']; ?>, <?php echo $event_id; ?>)"/></td> <td style="width: 20%;"> <form method="post" action=""> <input type="hidden" name="delete" value="<?php echo $column['id']; ?>"> <input type="hidden" name="event_id" value="<?php echo $event_id ?>"> <input name="imageDelete" type="submit" value="Delete" class="btn btn-primary btn-sm btn-block waves-effect text-center" /> </form> </td> <?php } ?> </table> </div> </div> </div> </div> </div> </div> </div> </div> </div> <?php include('footer.php'); ?>