ma<?php include 'inc/header.php'; ?>
<!-- ====== End Header ===== -->
<?php include 'inc/sidebar.php'; ?>

<!-- ====== End Sidebar ===== -->    
   <!-- Main Content -->
      <div class="main-content">
        <section class="section">
          <div class="section-header">
            <div class="row">
              <div class="col-xl-6 col-lg-6 col-md-6 col-sm-12">
                <div class="section-header-breadcrumb-content">
                  <h1> BLOGS</h1>
                  <div class="section-header-breadcrumb">
                    <div class="breadcrumb-item active"><a href="#"><i class="fas fa-home"></i></a></div>
                    <div class="breadcrumb-item"><a href="#">Blog</a></div>
                    <div class="breadcrumb-item"><a href="#"> Blog Post</a></div>
                  </div>
                </div>
              </div>
          </div>
          <div class="row">
              <div class="col-12">
                 <?php if (isset($_SESSION['msg_scs'])): ?>
            <p class="alert alert-success"><?= $_SESSION['msg_scs'];?></p>
          <?php endif ?>
          <?php unset($_SESSION['msg_scs']);?>
         
          <?php if (isset($_SESSION['msg_err'])): ?>
            <p class="alert alert-danger"><?= $_SESSION['msg_err'];?></p>
          <?php endif ?>
          <?php unset($_SESSION['msg_err']);?>
                <div class="card">
                  <div class="card-header">
                    <h4>Add Blog</h4>
                  </div>
                  <div class="card-body">
                  <form method="post" action="blog_insert.php" enctype="multipart/form-data">
              
            <div class="form-group">
              <label>Author</label>
         <input type="text" name="author" class="form-control">
              </select>
            </div>
            <div class="form-group">
              <label>Title</label>
              <input type="text" name="title" class="form-control">
            </div>
             <div class="form-group">
              <label>Image</label>
              <input type="file" name="image" class="form-control">
            </div>
        <div class="form-group">  
        <label>Description</label>  
        <textarea name="description" class="form-control ckeditor">
        </textarea>
    </div>
                      
       

          <button type="submit" class="btn btn-danger" name="update">Add Blog</button>
        </form>  
                  </div>
                </div>
              </div>
            </div>
       
            <br>
           

        <div class="row">
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Management</h4>
                  </div>
                  <div class="card-body">
                        <div class="table-responsive">
                          <table class="table table-bordered table-md">
                            <tbody><tr>
                              <th>id</th>
                              <th>Author</th>
                              
                              <th>Title</th>
                              <th>image</th>
                              <th>Description</th>
                              
                              <th>Action</th>
                            </tr>
                            <?php
                            

                            $data = "select * from blog";
                            //$run = $db->select($data);
                            $query = mysqli_query($con,$data);

                           while ($result = mysqli_fetch_array($query)) {

                              ?>
                               

                            
                            <tr>
                              <td><?php echo $result['id']?></td>
                              <td><?php echo $result['author']?></td>
                            
                            <td><?php echo$result['title']?></td>
                            <td>
                            <img src="<?php echo$result['image']?>" style="width: 70px;">
                             </td>
                             <td>
                             	<textarea><?php echo$result['description']?></textarea>
                             </td>
                              <td><a href="blog_edit.php?id=<?php echo $result['id']?>" class="btn btn-outline-primary" >Edit</a>
                                <a href="blog_delete.php?id=<?php echo $result['id']?>" class="btn btn-outline-primary">Delete</a></td>
                            </tr>
                          <?php
                          }
                          ?>

                          </tbody></table>
                        </div>
                  </div>


     

            </div>
          </div>
        </div>
               
<?php include 'inc/footer.php'; ?>
<!-- ====== End Footer ===== --> 

