<?php ob_start(); session_start(); include_once('../connect.php'); if(!isset($_SESSION['username'])) { header('location:login.php'); } ?> <?php $subject = $blog = $links = ''; $id = 0; if(isset($_GET['edit'])) { $id = $_GET['edit']; $sql = mysqli_query($db,"SELECT * FROM blogs where id = '$id'") or die(mysqli_error($db)); $row = mysqli_fetch_array($sql); $subject = $row['subject']; $date = $row['date']; $blog = $row['blog']; $links = $row['links']; } ?> <!DOCTYPE html> <html> <head> <title>PCC</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <link href="../css/custom_style.css" rel="stylesheet"> </head> <body> <?php include_once("edit_menu.php"); ?> <table class="table table-condensed table-bordered"> <form action='' method="post" enctype="multipart/form-data"> <tr> <td width="10%"><b>Date</b></td> <td><input type='date' name='date' class="form-control" value="<?php echo $date ?>"></td> </tr> <tr> <td><b>Product Name</b></td> <td><input type='text' autofocus name='subject' class="form-control" value="<?php echo $subject ?>"></td> </tr> <tr style='display:none'> <td><b>Description (Advice)</b></td> <td> <textarea name='blog' class="form-control" rows='5' cols="4"><?php echo $blog ?></textarea> </td> </tr> <tr> <td><b>Paste Link</b></td> <td> <textarea name='links' class="form-control" rows='5' cols="4"> <?php echo $links ?> </textarea> </td> </tr> <tr style='display:none'> <td><b>Image</b></td> <td><input type="file" name='image'></td> </tr> <tr> <td><input type='hidden' name='id' value="<?php echo $id ?>"></td> <td><input type='submit' name='submit' value="Submit" class="btn-primary" /></td> </tr> </form> </table> <div class='container-fluid'> <table class='table table-condensed table-striped'> <tr style="font-weight:bold"> <td>S.</td> <td width="7%">Date</td> <td>Medicine</td> <td>Link</td> <!-- <td>Description</td> <td>Img</td> --> <td>Edit</td> </tr> <?php $sql = mysqli_query($db,"SELECT * FROM blogs order by id desc limit 100"); $sql_count = mysqli_num_rows($sql); for($r=1;$r<=$sql_count;$r++) { $row = mysqli_fetch_array($sql); $blog = $row['blog']; $date = $row['date']; $dt = date('d-m-y',strtotime($date)); $subject = $row['subject']; $id = $row['id']; $links = $row['links']; echo " <tr> <td>$r</td> <td>$dt</td> <td>$subject</td> <td>$links</td> <td><a style='display:none' class='btn-primary' href='blog_entry.php?edit=$id'>Edit</a><br> <a class='btn-danger' href='blog_entry.php?del=$id'>Del</a> </td> </tr> "; } ?> </table> </div> <div id='footer'> </div> </body> </html> <?php if(isset($_GET['del'])) { $del = $_GET['del']; // //delete from folder // $sql = mysqli_query($db,"select image from blogs where id='$id'"); // $sqlrw = mysqli_fetch_array($sql); // $delfile = $sqlrw['image'].'.jpg'; // $add = 'blogs/'.$delfile; // unlink("$add"); // // $sql = mysqli_query($db,"DELETE FROM blogs where id = '$del'") or die(mysqli_error($db)); header("location:blog_entry.php"); } ?>