<?php
session_start();
include_once 'function.php';
// add Details
//`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1
//`homeid`, `homeimg1`, `homeimg2`, `homeimg3`, `homeimg4`, `homeimg5`, `homeimg6`SELECT * FROM `homepage` WHERE 1
if ($_POST['add'] == 'Create') {

    $homeimg1     = $_POST['homeimg1'];
    $homeimg2     = $_POST['homeimg2'];
    $homeimg3     = $_POST['homeimg3'];
    $homeimg4     = $_POST['homeimg4'];
    $homeimg5     = $_POST['homeimg5'];
    $homeimg6     = $_POST['homeimg6'];

$random_slider_image = rand(10000000, 99999999);
$homeimg1        = $_FILES['homeimg1']['name'];
if (!empty($homeimg1)) {
$file_size       = $_FILES['homeimg1']['size'];
$target_path     = "blog/";
$uploaded_slider_image1 = $random_slider_image . "_" . $_FILES['homeimg1']['name'];
move_uploaded_file($_FILES['homeimg1']['tmp_name'], $target_path . $random_slider_image . "_" . $_FILES['homeimg1']['name']);
} else {
$uploaded_slider_image1 = "";
}


$homeimg2        = $_FILES['homeimg2']['name'];
if (!empty($homeimg2)) {
$file_size       = $_FILES['homeimg2']['size'];
$target_path     = "blog/";
$uploaded_slider_image2 = $random_slider_image . "_" . $_FILES['homeimg2']['name'];
move_uploaded_file($_FILES['homeimg2']['tmp_name'], $target_path . $random_slider_image . "_" . $_FILES['homeimg2']['name']);
} else {
$uploaded_slider_image2 = "";
}

$homeimg3       = $_FILES['homeimg3']['name'];
if (!empty($homeimg3)) {
$file_size       = $_FILES['homeimg3']['size'];
$target_path     = "blog/";
$uploaded_slider_image2 = $random_slider_image . "_" . $_FILES['newsimg2']['name'];
move_uploaded_file($_FILES['homeimg3']['tmp_name'], $target_path . $random_slider_image . "_" . $_FILES['homeimg3']['name']);
} else {
$uploaded_slider_image3 = "";
}

$homeimg4        = $_FILES['homeimg4']['name'];
if (!empty($homeimg4)) {
$file_size       = $_FILES['homeimg4']['size'];
$target_path     = "blog/";
$uploaded_slider_image2 = $random_slider_image . "_" . $_FILES['homeimg4']['name'];
move_uploaded_file($_FILES['homeimg4']['tmp_name'], $target_path . $random_slider_image . "_" . $_FILES['homeimg4']['name']);
} else {
$uploaded_slider_image4 = "";
}

$homeimg5       = $_FILES['homeimg5']['name'];
if (!empty($homeimg5)) {
$file_size       = $_FILES['homeimg5']['size'];
$target_path     = "blog/";
$uploaded_slider_image2 = $random_slider_image . "_" . $_FILES['homeimg5']['name'];
move_uploaded_file($_FILES['homeimg5']['tmp_name'], $target_path . $random_slider_image . "_" . $_FILES['homeimg5']['name']);
} else {
$uploaded_slider_image5 = "";
}

$homeimg6        = $_FILES['homeimg6']['name'];
if (!empty($homeimg6)) {
$file_size       = $_FILES['homeimg6']['size'];
$target_path     = "blog/";
$uploaded_slider_image2 = $random_slider_image . "_" . $_FILES['homeimg6']['name'];
move_uploaded_file($_FILES['homeimg6']['tmp_name'], $target_path . $random_slider_image . "_" . $_FILES['homeimg6']['name']);
} else {
$uploaded_slider_image6 = "";
}



$today = date('Y-m-d');
//`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1
//`homeid`, `homeimg1`, `homeimg2`, `homeimg3`, `homeimg4`, `homeimg5`, `homeimg6`SELECT * FROM `homepage` WHERE 1


mysqli_query($connect,"INSERT into news (`categoryid`,`homeimg1`,`homeimg2`,`homeimg3`,`homeimg4`,`homeimg5`,`homeimg6`) 
values ('$categoryid','$homeimg1','$homeimg2','$homeimg3','$homeimg4','$homeimg5','$homeimg3','$uploaded_slider_image1','$uploaded_slider_image2')") or die(mysqli_error());



echo "<div style='width: 350px; text-align: center; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid #ddd; padding: 20px 40px;'> 
Please wait while we update loading...</div>";
echo "<script type='text/javascript'>window.location = 'homepage.php?msg=added&action=list'</script>";
}
// Edit
if ($_POST['update_page'] == 'Update') {


$newsid = $_POST['newsid'];


$newshead     = $_POST['newshead'];
$newsdate     = $_POST['newsdate'];
$newscontent     = $_POST['newscontent'];

$newsimg1     = $_POST['newsimg1'];
$newsimg2     = $_POST['newsimg2'];
$categoryid     = $_POST['categoryid'];


// dress1
$old_slider_image1 = $_POST['old_slider_image1'];
$random_no = rand(10000000, 99999999);
$newsimg1        = $_FILES['newsimg1']['name'];
if (!empty($newsimg1)) {
$file_size       = $_FILES['newsimg1']['size'];
$target_path     = "blog/";
$uploaded_slider_image1 = $random_no . "_" . $_FILES['newsimg1']['name'];
move_uploaded_file($_FILES['newsimg1']['tmp_name'], $target_path . $random_no . "_" . $_FILES['newsimg1']['name']);
// Old image
$oldimage_path = $target_path.$old_slider_image1;
unlink($oldimage_path);
} else {
$uploaded_slider_image1 = $old_slider_image1;
}

// dress1
$old_slider_image2 = $_POST['old_slider_image2'];
$random_no = rand(10000000, 99999999);
$newsimg2        = $_FILES['newsimg2']['name'];
if (!empty($newsimg2)) {
$file_size       = $_FILES['newsimg2']['size'];
$target_path     = "blog/";
$uploaded_slider_image2 = $random_no . "_" . $_FILES['newsimg2']['name'];
move_uploaded_file($_FILES['newsimg2']['tmp_name'], $target_path . $random_no . "_" . $_FILES['newsimg2']['name']);
// Old image
$oldimage_path = $target_path.$old_slider_image2;
unlink($oldimage_path);
} else {
$uploaded_slider_image2 = $old_slider_image2;
}

//`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1

$today = date('Y-m-d');
//SELECT * FROM `gallery` WHERE`galleryid`, `galleryimg` 1
mysqli_query($connect,"UPDATE news SET `categoryid` = '$categoryid',`newsdate` = '$today',`newshead` = '$newshead',`newscontent` = '$newscontent',`newsimg1` = '$uploaded_slider_image1',`newsimg2` = '$uploaded_slider_image2'  where newsid = '$newsid'") or die(mysqli_error());
echo "<div style='width: 350px; text-align: center; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid #ddd; padding: 20px 40px;'> 
Please wait while we update loading...</div>";
echo "<script type='text/javascript'>window.location = 'news.php?msg=updated&action=list'</script>";
}
//`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1
if ($_GET['action'] == 'delete') {
$id  = $_GET['nwsevnt_id'];
$sql = "DELETE FROM news WHERE newsid = $id;";
$query = mysqli_query($connect,$sql) or die("There was a problem while deleting: " . mysqli_error());
echo "<div style='width: 350px; text-align: center; margin: 20% auto 0px; font-family: arial; font-size: 14px; border: 1px solid #ddd; padding: 20px 40px;'>Please wait while we update the record loading...</div>";
echo "<script type='text/javascript'>window.location = 'slider.php?msg=deleted&action=list'</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />   
  <head>
    <meta charset="utf-8" />
    <title>NEWS | 
      <?php echo $site_title; ?>
    </title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">    
    <link rel="stylesheet" href="assets/font-awesome/font-awesome.min.css"> 
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&amp;subset=all" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
    <!-- END GLOBAL MANDATORY STYLES -->
    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <link href="assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
    <!-- END PAGE LEVEL PLUGINS -->
    <!-- BEGIN THEME GLOBAL STYLES -->
    <link href="assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
    <link href="assets/global/css/plugins.min.css" rel="stylesheet" type="text/css" />
    <!-- END THEME GLOBAL STYLES -->
    <!-- BEGIN THEME LAYOUT STYLES -->
    <link href="assets/layouts/layout/css/layout.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/layouts/layout/css/themes/darkblue.min.css" rel="stylesheet" type="text/css" id="style_color" />
    <link href="assets/layouts/layout/css/custom.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.css" rel="stylesheet" type="text/css" />
    <link href="assets/layouts/customer.css" rel="stylesheet" type="text/css" />
    <!-- END PAGE LEVEL PLUGINS -->
    <style type="text/css">
      .dt-buttons {
        display: none;
      }
    </style>
    <script type="text/javascript">
      function delete_menu(idurl)
      {
        go_on = confirm("Are you sure ? ");
        if(go_on)
        {
          document.location.href=idurl;
        }
      }
    </script>
  </head>
  <!-- END HEAD -->
  <body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white">
    <div class="page-wrapper">
      <!-- BEGIN HEADER -->
      <?php include("header.php");?>
      <!-- END HEADER -->
      <!-- BEGIN HEADER & CONTENT DIVIDER -->
      <div class="clearfix"> 
      </div>
      <!-- END HEADER & CONTENT DIVIDER -->
      <!-- BEGIN CONTAINER -->
      <div class="page-container">
        <!-- BEGIN SIDEBAR -->
        <?php include("menu.php");?>
        <!-- END SIDEBAR -->
        <!-- BEGIN CONTENT -->
        <div class="page-content-wrapper">
          <!-- BEGIN CONTENT BODY -->
          <div class="page-content">
            <!-- END THEME PANEL -->
            <!-- BEGIN PAGE BAR -->
            <div class="page-bar">
              <ul class="page-breadcrumb">
                <li>
                  <a href="index.php">Home
                  </a>
                  <i class="fa fa-circle">
                  </i>
                </li>
                <li>
                  <span>News
                  </span>
                </li>
              </ul>
              <div class="page-toolbar">
                <div id="dashboard-report-range" class="pull-right tooltips btn btn-sm" data-container="body" data-placement="bottom" data-original-title="Change dashboard date range">
                  <i class="icon-calendar">
                  </i>&nbsp;
                  <span class="thin uppercase hidden-xs">
                  </span>&nbsp;
                  <i class="fa fa-angle-down">
                  </i>
                </div>
              </div>
            </div>
            <!-- END PAGE BAR -->
            <!-- BEGIN PAGE TITLE-->
            <?php
//get action 
if(isset($_GET['action']) =='' || $_GET['action'] == 'list') {
    //`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1
?>
            <br>
            <div class="row">
              <div class="col-md-12">
                <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="portlet box red">
                  <div class="portlet-title">
                    <div class="caption">
                      <i class="fa fa-globe">
                      </i>News
                    </div>
                    <div class="actions">
                      <a href="?action=add" class="btn btn-default btn-sm">
                        <i class="fa fa-plus">
                        </i> Add 
                      </a>
                    </div>
                  </div>
                  <div class="portlet-body">
                    <?php pageStatus($status); ?>
                    <table class="table table-striped table-bordered table-hover" id="sample_2">
                      <thead>
                        <tr class="">
                          <th> S.NO 
                          </th>
                          <th>
                            Date
                          </th>
                          <th>
                        Category
                          </th>
                          <th>
                            News Heading
                          </th>
                          <th>
                            View
                          </th>
                          <th>Modify
                          </th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php
$sno =0;
    //`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1
$get_organic = mysqli_query($connect,"SELECT * FROM `news` ") or die(mysqli_error());
while($get_value = mysqli_fetch_array($get_organic)) 
{
$sno++;
$newsid = $get_value['newsid'];

$newsdate = $get_value['newsdate'];
$newshead = $get_value['newshead'];
$newscontent = $get_value['newscontent'];
$newsimg1 = $get_value['newsimg1'];
$newsimg2 = $get_value['newsimg2'];
$categoryid = $get_value['categoryid'];

?>
                        <tr>
                          <td>
                            <?php echo $sno;?> 
                          </td>
                          <td>
                            <?php echo date('d-m-Y',strtotime($newsdate));?> 
                          </td>
                          <td>
                            <?php echo categoryDB($categoryid);?> 
                          </td>
                          
                          <td>
                            <?php echo $newshead;?> 
                          </td>
                          
                          
                          
                          <td>
                            <a class="btn btn-info btn-xs" data-toggle="modal" href="#image<?php echo $newsid; ?>">
                              <i class="fa fa-eye" aria-hidden="true">
                              </i> View 
                            </a>
                          </td>
                          <td>
                            <a class="btn btn-warning  btn-xs" href="news.php?action=edit&nwsevnt_id=<?php echo base64_encode($newsid); ?>">
                              <i class="fa fa-pencil" aria-hidden="true">
                              </i> Edit
                            </a>
                            <a class="btn btn-xs red"  onClick="delete_menu('news.php?action=delete&nwsevnt_id=<?php echo $newsid; ?>')" href="javascript:;">
                              <i class="icon-trash">
                              </i> Delete
                            </a>
                          </td>
                          <!--============================================= Message Pop Up =============================================-->
                          
                          <!--=========================================== End Message Pop Up ========================================== -->

                          <!--============================================= Content Pop Up =============================================-->
                          
                          <!--=========================================== End Content Pop Up ============================================== -->


                          <!--============================================= Image View Pop Up =============================================-->
                          <div class="modal fade" id="image<?php echo $newsid; ?>" tabindex="-1" role="basic" aria-hidden="true">
                            <div class="modal-dialog">
                              <div class="modal-content">
                                <div class="modal-header">
                                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                  </button>
                                  <h4 class="modal-title">
                                    <b>
                                      <?php echo $newshead;?>
                                    </b>
                                  </h4>
                                </div>
                                <div class="modal-body">
                                  <img src="blog/<?php echo $newsimg1; ?>" class="img-responsive">
                                  <img src="blog/<?php echo $newsimg2; ?>" class="img-responsive">
                                  <p>
                                    <?php echo $newscontent; ?>
                                    </p>
                                </div>
                                <div class="modal-footer">
                                  <button type="button" class="btn dark btn-outline" data-dismiss="modal">Close
                                  </button>
                                </div>
                              </div>
                              <!-- /.modal-content -->
                            </div>
                            <!-- /.modal-dialog -->
                          </div>
                          <!--=========================================== End Image Pop Up ============================================== -->

                        </tr>
                        <?php
}
?>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>   
            <?php
}
if($_GET['action'] == 'add')
{
  //SELECT * FROM `gallery` WHERE`galleryid`, `galleryimg` 1
      //`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1
?>
            <div class="row">
              <div class="col-md-12">
                <!-- BEGIN VALIDATION STATES-->
                <div class="portlet light portlet-fit portlet-form bordered">
                  <div class="portlet-title">
                    <div class="caption">
                      <i class="fa fa-list  font-red" aria-hidden="true">
                      </i>
                      <span class="caption-subject font-red sbold uppercase">ADD 
                      </span>
                    </div>
                  </div>
                  <div class="portlet-body">
                    <!-- BEGIN FORM-->
                    <form action="" id="form_sample_1" method="post" class="form-horizontal" novalidate="novalidate" enctype="multipart/form-data" onsubmit="return CheckFormData();">
                      <div class="form-body">


                      <div class="form-group">
                                                    <label class="control-label col-md-3">Category
                                                        <span class="required" aria-required="true"> * </span>
                                                    </label>
                                                    <div class="col-md-4">
                                                        <select name="categoryid" id="categoryid"  data-required="1" class="form-control">
                                                            <?php
 
                                                //`categoryid`, `categoryname`SELECT * FROM `category` WHERE 1
                                                $get_organiccategory = mysqli_query($connect,"SELECT * FROM `category` ") or die(mysqli_error());
                                                while($get_valuecategory = mysqli_fetch_array($get_organiccategory)) 
                                                {
                                             
                                                    $categoryid = $get_valuecategory['categoryid'];
                                                    $categoryname = $get_valuecategory['categoryname'];
                                                   
                                                            ?>
                                            <option value="<?php echo $categoryid; ?>"><?php echo $categoryname; ?></option>
                                            <?php
                                                }
                                                ?>
                                        </select>                        
                                
                                  
                               </div>
                               </div>
                        
                        
                      <div class="form-group">
                                                    <label class="control-label col-md-3">News Heading
                                                        <span class="required" aria-required="true"> * </span>
                                                    </label>
                                                    <div class="col-md-4">
                                                        <input type="text" name="newshead" id="newshead" data-required="1" class="form-control">
                                  
                               </div>
                               </div>

                               <div class="form-group">
                                                    <label class="control-label col-md-3">News Content
                                                        <span class="required" aria-required="true"> * </span>
                                                    </label>
                                                    <div class="col-md-4">
         <!-- <input type="text" name="newshead" id="newshead" data-required="1" class="form-control"> -->
         <textarea name="newscontent" id="newscontent" class="form-control" data-required="1" style="height:300px;" ></textarea>
                                  
                               </div>
                               </div>
                        
                        <div class="form-group last">
                          <label class="control-label col-md-3">Image 1
                          </label>
                          <div class="col-md-9">
                            <div class="fileinput fileinput-new" data-provides="fileinput">
                              <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                                <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""> 
                              </div>
                              <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> 
                              </div>
                              <div>
                                <span class="btn default btn-file">
                                  <span class="fileinput-new"> Select image 
                                  </span>
                                  <span class="fileinput-exists"> Change 
                                  </span>
                                  <input type="file" name="newsimg1" id="image"> 
                                </span>
                                <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Remove 
                                </a>
                              </div>
                            </div>
                          </div>
                        </div>


                        <div class="form-group last">
                          <label class="control-label col-md-3">Image 2
                          </label>
                          <div class="col-md-9">
                            <div class="fileinput fileinput-new" data-provides="fileinput">
                              <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                                <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""> 
                              </div>
                              <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> 
                              </div>
                              <div>
                                <span class="btn default btn-file">
                                  <span class="fileinput-new"> Select image 
                                  </span>
                                  <span class="fileinput-exists"> Change 
                                  </span>
                                  <input type="file" name="newsimg2" id="image"> 
                                </span>
                                <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Remove 
                                </a>
                              </div>
                            </div>
                          </div>
                        </div>

                      </div>
                      <div class="form-actions">
                        <div class="row">
                          <div class="col-md-offset-3 col-md-9">
                            <button type="submit" class="btn green" name="add" value="Create">Submit
                            </button>
                            <button type="reset" value="Reset" class="btn grey-salsa btn-outline">Reset
                            </button>
                          </div>
                        </div>
                      </div>
                    </form>
                    <!-- END FORM-->
                  </div>
                </div>
                <!-- END VALIDATION STATES-->
              </div>
            </div>
            <?php
}
if(isset($_GET['action']) == 'edit' && isset($_GET['nwsevnt_id'])) {   
      //`newsid`, `newsdate`, `newshead`, `newscontent`, `newsimg1`, `newsimg2`SELECT * FROM `news` WHERE 1                       
$NewsID = base64_decode($_GET["nwsevnt_id"]);

$get_about_edit = mysqli_query($connect,"SELECT * FROM `news` where newsid = '$NewsID'") or die(mysqli_error());
while($get_edit = mysqli_fetch_array($get_about_edit)) 
{
$sno++;
$newsid = $get_edit['newsid'];

$newshead = $get_edit['newshead'];
$newscontent = $get_edit['newscontent'];
$newsimg1 = $get_edit['newsimg1'];
$newsimg2 = $get_edit['newsimg2'];

$categoryiD = $get_edit['categoryid'];
}
?>
            <div class="row">
              <div class="col-md-12">
                <!-- BEGIN VALIDATION STATES-->
                <div class="portlet light portlet-fit portlet-form bordered">
                  <div class="portlet-title">
                    <div class="caption">
                      <i class="fa fa-pencil font-red" aria-hidden="true">
                      </i>
                      <span class="caption-subject font-red sbold uppercase">Edit 
                      </span>
                    </div>
                  </div>
                  <div class="portlet-body">
                    <!-- BEGIN FORM-->
                    <form action="" id="form_sample_1" method="post" class="form-horizontal" novalidate="novalidate" enctype="multipart/form-data">
                      <div class="form-body">
                        
                      <div class="form-group">
                                                    <label class="control-label col-md-3">Category
                                                        <span class="required" aria-required="true"> * </span>
                                                    </label>
                                                    <div class="col-md-4">
        <select name="categoryid" id="categoryid"  data-required="1" class="form-control">
                                                                        <?php
            
                                                            //`categoryid`, `categoryname`SELECT * FROM `category` WHERE 1
                                                            $get_organiccategory = mysqli_query($connect,"SELECT * FROM `category` ") or die(mysqli_error());
                                                            while($get_valuecategory = mysqli_fetch_array($get_organiccategory)) 
                                                            {
                                                        
                                                                $categoryid = $get_valuecategory['categoryid'];
                                                                $categoryname = $get_valuecategory['categoryname'];
                                                            
                                                                        ?>
            <option value="<?php echo $categoryid; ?>" <?php if($categoryiD == $categoryid){ echo "selected";} ?>><?php echo $categoryname; ?></option>
                                                        <?php
                                                            }
                                                            ?>
                                                    </select>                        
                                
                                  
                               </div>
                               </div>
                        
                        
                      <div class="form-group">
                                                    <label class="control-label col-md-3">News Heading
                                                        <span class="required" aria-required="true"> * </span>
                                                    </label>
                                                    <div class="col-md-4">
          <input type="text" name="newshead" id="newshead" data-required="1" class="form-control" value="<?php echo $newshead; ?>">
                                  
                               </div>
                               </div>

                               <div class="form-group">
                                                    <label class="control-label col-md-3">News Content
                                                        <span class="required" aria-required="true"> * </span>
                                                    </label>
                                                    <div class="col-md-4">
         <!-- <input type="text" name="newshead" id="newshead" data-required="1" class="form-control"> -->
         <textarea name="newscontent" id="newscontent" class="form-control" data-required="1" style="height:300px;" ><?php echo $newscontent; ?></textarea>
                                  
                               </div>
                               </div>
                        
                        <div class="form-group last">
                          <label class="control-label col-md-3">Image 1
                          </label>
                          <div class="col-md-9">
                            <div class="fileinput fileinput-new" data-provides="fileinput">
                            <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                                <img src="blog/<?php echo $newsimg1; ?>" alt=""> 
                              </div>
                              <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> 
                              </div>
                              <div>
                                <span class="btn default btn-file">
                                  <span class="fileinput-new"> Select image 
                                  </span>
                                  <span class="fileinput-exists"> Change 
                                  </span>
                                  <input type="file" name="newsimg1" id="image"> 
                                </span>
                                <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Remove 
                                </a>
                              </div>
                            </div>
                          </div>
                        </div>


                        <div class="form-group last">
                          <label class="control-label col-md-3">Image 2
                          </label>
                          <div class="col-md-9">
                            <div class="fileinput fileinput-new" data-provides="fileinput">
                            <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                                <img src="blog/<?php echo $newsimg2; ?>" alt=""> 
                              </div>
                              <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> 
                              </div>
                              <div>
                                <span class="btn default btn-file">
                                  <span class="fileinput-new"> Select image 
                                  </span>
                                  <span class="fileinput-exists"> Change 
                                  </span>
                                  <input type="file" name="newsimg2" id="image"> 
                                </span>
                                <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Remove 
                                </a>
                              </div>
                            </div>
                          </div>
                        </div>


                      </div>
                      <div class="form-actions">
                        <div class="row">
                          <div class="col-md-offset-3 col-md-9">
                            <input type="hidden" name="newsid" value="<?php echo $newsid; ?>">
                            <input type="hidden" name="old_slider_image1" value="<?php echo $newsimg1; ?>">
                            <input type="hidden" name="old_slider_image2" value="<?php echo $newsimg2; ?>">
                            <button type="submit" class="btn green" name="update_page" value="Update">Update
                            </button>
                            <button type="reset" value="Reset" class="btn grey-salsa btn-outline">Reset
                            </button>
                          </div>
                        </div>
                      </div>
                    </form>
                    <!-- END FORM-->
                  </div>
                </div>
                <!-- END VALIDATION STATES-->
              </div>
            </div>
            <?php
}

?>
            <div class="clearfix">
            </div>
          </div>
          <!-- END CONTENT BODY -->
        </div>
        <!-- END CONTENT -->
        <!-- END QUICK SIDEBAR -->
      </div>
      <!-- END CONTAINER -->
      <!-- BEGIN FOOTER -->
      <?php include("footer.php");?>
      <!-- END FOOTER -->
    </div>
    <!-- BEGIN QUICK NAV -->
    <div class="quick-nav-overlay">
    </div>
    <!-- END QUICK NAV -->
    <!--[if lt IE 9]>
<script src="assets/global/plugins/respond.min.js"></script>
<script src="assets/global/plugins/excanvas.min.js"></script> 
<script src="assets/global/plugins/ie8.fix.min.js"></script> 
<![endif]-->
    <!-- BEGIN CORE PLUGINS -->
    <script src="//cdn.ckeditor.com/4.5.7/standard/ckeditor.js">
    </script>
    <script src="assets/global/plugins/jquery.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/js.cookie.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/jquery.blockui.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript">
    </script>
    <!-- END CORE PLUGINS -->
    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <script src="assets/global/scripts/datatable.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/datatables/datatables.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.js" type="text/javascript">
    </script>
    <!-- END PAGE LEVEL PLUGINS -->
    <!-- BEGIN THEME GLOBAL SCRIPTS -->
    <script src="assets/global/scripts/app.min.js" type="text/javascript">
    </script>
    <!-- END THEME GLOBAL SCRIPTS -->
    <!-- BEGIN PAGE LEVEL SCRIPTS -->
    <script src="assets/pages/scripts/table-datatables-colreorder.min.js" type="text/javascript">
    </script>
    <!-- BEGIN PAGE LEVEL PLUGINS -->
    <script src="assets/global/plugins/select2/js/select2.full.min.js" type="text/javascript">
    </script>
    <!-- END PAGE LEVEL PLUGINS -->
    <!-- BEGIN PAGE LEVEL SCRIPTS -->
    <script src="assets/pages/scripts/components-select2.min.js" type="text/javascript">
    </script>
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- BEGIN THEME LAYOUT SCRIPTS -->
    <script src="assets/layouts/layout/scripts/layout.min.js" type="text/javascript">
    </script>
    <script src="assets/layouts/layout/scripts/demo.min.js" type="text/javascript">
    </script>
    <script src="assets/layouts/global/scripts/quick-sidebar.min.js" type="text/javascript">
    </script>
    <script src="assets/layouts/global/scripts/quick-nav.min.js" type="text/javascript">
    </script>
    <script src="assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.js" type="text/javascript">
    </script>
    <!-- END THEME LAYOUT SCRIPTS -->
    <!-- Password Check -->
    <script language="javascript">
      function pswcheck()
      {
        pass=document.getElementById("password").value;
        repassword=document.getElementById("repassword").value;
        if(pass!=repassword)
        {
          alert("password Mismatch");
          document.getElementById("password").value="";
          document.getElementById("repassword").value="";
          document.getElementById("password").focus();
        }
      }
    </script>
    <script language="javascript" type="text/javascript">
      function CheckFormData()
      {
        var organic_menu  = document.getElementById("organic_menu");
        var image  = document.getElementById("image");
        if(organic_menu.value == '')
        {
          alert('Please Fill Category.');
          organic_menu.focus();
          organic_menu.style.border = 'thin solid red';
          return false;
        }
        if(image.value == '')
        {
          alert('Please Select Image.');
          image.focus();
          image.style.border = 'thin solid red';
          return false;
        }
        return true;
      }
    </script>
  </body>
</html>
