<?php
error_reporting(0);
ob_start();
session_start();
require_once("../dbconnect.php");
if(isset($_POST['submit']) )
  {
  $query="Update mec_texteditor SET mec_content='".addslashes($_POST['workdetails'])."' where mec_edit_id=".$_POST['mec_edit_id'];
  mysql_query($query) or die("Query failed in updating aboutus: " . mysql_error());
  header("location:texteditor.php?suc=suc");
  }
?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
     <style type="text/css">

      /* Sticky footer styles
      -------------------------------------------------- */

     

    </style>
    	
   <?php include_once("title.php"); ?>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/main.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/logo-nav.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>
     <div id="wrap">
    <!-- Navigation -->
        <?php include_once("header.php"); ?>

    <!-- Page Content -->
    <div class="container">
        <div class="row">
            <div class="col-lg-12">

                 <div class="row">
                 <br><br><br> <br><br><br>
        <h1> Edit Pages </h1>
        <div class="col-lg-3 col-sm-6"><div class="well">
          <table class="table table-striped table-bordered">
              <thead>
              <tr><th>Id</th><th>Page Name</th></tr>
              </thead>

              <tbody>
                <?php

			$query=mysql_query("Select * from mec_texteditor"); $i=1;

			while($storerow=mysql_fetch_array($query))

		      {

					 ?>
                  <tr><td><?php echo $i; ?></td><td><a href="texteditor.php?mec_edit_id=<?php echo $storerow['mec_edit_id']; ?>"><?php echo $storerow['mec_pagename']; ?></a></td></tr>
                  <?php $i++; } ?>
                  
              </tbody>
          </table>
        </div>
        </div>
        
        <div class="col-lg-9 col-sm-6">
            <div class="well"><?php if($_GET['mec_edit_id']!="") {?>

					<?php $QUERYDIS="SELECT * FROM mec_texteditor WHERE mec_edit_id=".$_GET['mec_edit_id'];

						     $EXEDIS=mysql_query($QUERYDIS);

							 $row=mysql_fetch_array($EXEDIS);

						  ?>
            <form name='form1' action="" method="post" enctype="multipart/form-data">
                <table class="table table-striped table-condensed">
                    <thead><tr><th><?php echo stripslashes($row['mec_pagename']); ?></th></tr></thead>

                    <tbody>
                   
                    <tr><td><div id="txtEditor"></div><script src="//cdn.ckeditor.com/4.5.8/full/ckeditor.js"></script>

 <textarea name="workdetails"><?php echo stripslashes($row['mec_content']); ?></textarea>
     <?php if($_GET['mec_edit_id']!=1 and $_GET['mec_edit_id']!=2) {?>
        <script>
            CKEDITOR.replace( 'workdetails' );
        </script>
        <?php } ?>
        </td></tr>
                    
                    <tr><td style="text-align: center;"><button type="submit" class="btn btn-info"><i class="glyphicon glyphicon-edit"></i> Modify</button></td></tr>
                    </tbody></table>
                     <input type="hidden" name="submit" value="submit1">
                    <input type="hidden" name="mec_edit_id" value="<?php echo $_GET['mec_edit_id']; ?>">
                    </form>
                    <?php } ?>
                    <?php
					if($_GET['suc']=="suc"){
					?>
                    <p style="font-size:18px; text-align:center; color:#00F;">Succesfully Modified!</p>
                    <?php } ?>
       
        </div>
        </div>
    </div>

                
               
    </div>

        </div>

  

            </div>
            
         <div id="push"></div>
    </div>

     <?php include_once("footer.php"); ?>
   

    
    <!-- /.container -->

    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
 
   
<link href="../css/editor.css" type="text/css" rel="stylesheet"/>
<script src="../js/editor.js"></script>
</body>

</html>
