title: activate and deactivate mysql record using php
body: <p>Hi I'm working on user management system. I'm displays all records from db and add, edit and delete operations are successfully performed. now I'm need to display in home page as only active records from Mysql table. i have 2 links in my admin control one is activate and another is deactivate. if i click activate the records will display in home page and deactivate means records will hide in home page. i'm inserted field status with</p>
  
  <pre><code>datatype enum('active','deactive')`.
  </code></pre>
  
  <p>my coding are below. In coding what changes i need it?</p>
  
  <p><strong>Index.php:</strong></p>
  
  <pre><code>&lt;form method="post"&gt;
  &lt;table&gt;
  
      &lt;tr&gt;
          &lt;td&gt;Title:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="title" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Author&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="author" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Publisher Name&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="name" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Copyright Year&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="copy" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&lt;input type="submit" name="submit" value="add" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;?php
  if (isset($_POST['submit']))
      {      
      include 'db.php';
  
                      $title=$_POST['title'] ;
                      $author= $_POST['author'] ;                 
                      $name=$_POST['name'] ;
                      $copy=$_POST['copy'] ;
  
           mysql_query("INSERT INTO `books`(Title,Author,PublisherName,CopyrightYear) 
           VALUES ('$title','$author','$name','$copy')"); 
  
  
              }
  ?&gt;
  &lt;/form&gt;
  &lt;table border="1"&gt;
  
              &lt;?php
              include("db.php");
  
  
              $result=mysql_query("SELECT * FROM books");
  
              while($test = mysql_fetch_array($result))
              {
                  $id = $test['BookID'];  
                  echo "&lt;tr align='center'&gt;"; 
                  echo"&lt;td&gt;&lt;font color='black'&gt;" .$test['BookID']."&lt;/font&gt;&lt;/td&gt;";
                  echo"&lt;td&gt;&lt;font color='black'&gt;" .$test['Title']."&lt;/font&gt;&lt;/td&gt;";
                  echo"&lt;td&gt;&lt;font color='black'&gt;". $test['Author']. "&lt;/font&gt;&lt;/td&gt;";
                  echo"&lt;td&gt;&lt;font color='black'&gt;". $test['PublisherName']. "&lt;/font&gt;&lt;/td&gt;";
                  echo"&lt;td&gt;&lt;font color='black'&gt;". $test['CopyrightYear']. "&lt;/font&gt;&lt;/td&gt;"; 
                  echo"&lt;td&gt; &lt;a href ='view.php?BookID=$id'&gt;Edit&lt;/a&gt;";
                  echo"&lt;td&gt; &lt;a href ='view.php?BookID=$id'&gt;Activate&lt;/a&gt;";
                  echo"&lt;td&gt; &lt;a href ='view.php?BookID=$id'&gt;Deactivate&lt;/a&gt;";
                  echo"&lt;td&gt; &lt;a href ='del.php?BookID=$id'&gt;&lt;center&gt;Delete&lt;/center&gt;&lt;/a&gt;";
  
                  echo "&lt;/tr&gt;";
              }
              mysql_close($conn);
              ?&gt;
  &lt;/table&gt;
  
  View.php:
  &lt;?php
  require("db.php");
  $id =$_REQUEST['BookID'];
  
  $result = mysql_query("SELECT * FROM books WHERE BookID  = '$id'");
  $test = mysql_fetch_array($result);
  if (!$result) 
          {
          die("Error: Data not found..");
          }
                  $Title=$test['Title'] ;
                  $Author= $test['Author'] ;                  
                  $PublisherName=$test['PublisherName'] ;
                  $CopyrightYear=$test['CopyrightYear'] ;
  
  if(isset($_POST['save']))
  {   
      $title_save = $_POST['title'];
      $author_save = $_POST['author'];
      $name_save = $_POST['name'];
      $copy_save = $_POST['copy'];
  
      mysql_query("UPDATE books SET Title ='$title_save', Author ='$author_save',
           PublisherName ='$name_save',CopyrightYear ='$copy_save' WHERE BookID = '$id'")
                  or die(mysql_error()); 
      echo "Saved!";
  
      header("Location: index.php");          
  }
  mysql_close($conn);
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form method="post"&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;Title:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="title" value="&lt;?php echo $Title ?&gt;"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Author&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="author" value="&lt;?php echo $Author ?&gt;"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Publisher Name&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="name" value="&lt;?php echo $PublisherName ?&gt;"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Copyright Year&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="copy" value="&lt;?php echo $CopyrightYear ?&gt;"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&lt;input type="submit" name="save" value="save" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>del.php:</strong></p>
  
  <pre><code>&lt;?php
    include("db.php");  
  
      $id =$_REQUEST['BookID'];
  
  
      // sending query
      mysql_query("DELETE FROM books WHERE BookID = '$id'")
      or die(mysql_error());      
  
      header("Location: index.php");
  ?&gt;
  </code></pre>
  
  <p>please give some ideas or codings. this is first time i'm using this concept.??</p>