title: how to update database using php,mysql
body: <p>hi i am developing hotel website. I have a page which is show all available and booked room in a page using php and mysql.the booked room display as red background color with Exclamation button. if i click that exclamation marked button room status should be change from booked to available. his same function should be done in available room portion. available room should be display with green background color with tick button. if click tick button available status should be change from available to booked.</p>
  
  <p>here is my html code</p>
  
  <pre><code>&lt;?php while($row = mysql_fetch_array($result)):;?&gt;
                  &lt;div class="w3-small"&gt;
                    &lt;?php if ($row['status'] == 'available'){ 
                          echo"&lt;div class='w3-container w3-green w3-text-white w3-padding-small'&gt;
                              &lt;div class='w3-left'&gt;&lt;i class='fa fa-users w3-tiny'&gt;&lt;/i&gt;&lt;/div&gt;
                              &lt;div class='w3-right'&gt;".
                              "&lt;h3 name='$row[0]'&gt;".$row['roomno']."&lt;/h3&gt;".
                              "&lt;/div&gt;".
                            "&lt;div class='w3-clear'&gt;&lt;/div&gt;";
                          echo "&lt;form action='editstatus.php' method='POST'&gt;&lt;button class='buttonmark buttoncan' name='available'&gt;&lt;i class='fa fa-exclamation-triangle'&gt;&lt;/i&gt;&lt;/button&gt;&lt;/form&gt;&lt;/div&gt;";
                          }
                          elseif ($row['status']== 'booked') {
                            echo"&lt;div class='w3-container w3-red w3-text-white w3-padding-small'&gt;
                              &lt;div class='w3-left'&gt;&lt;i class='fa fa-users w3-tiny'&gt;&lt;/i&gt;&lt;/div&gt;
                              &lt;div class='w3-right'&gt;".
                              "&lt;h3 name='$row[0]'&gt;".$row['roomno']."&lt;/h3&gt;".
                              "&lt;/div&gt;".
                            "&lt;div class='w3-clear'&gt;&lt;/div&gt;";
                          echo "&lt;form action='editstatus.php' method='POST'&gt;&lt;button class='buttonmark buttonok' name='booked'&gt;&lt;i class='fa fa-check-square-o'&gt;&lt;/i&gt;&lt;/button&gt;&lt;/form&gt;&lt;/div&gt;";
                          }
                        ?&gt;
                          &lt;br&gt; &lt;br&gt;
                  &lt;/div&gt;
                &lt;?php endwhile;?&gt; 
  </code></pre>
  
  <p>my php code is</p>
  
  <pre><code>&lt;?php
  ob_start(); //After ob_start this output is saved in output buffer, so you can later decide what to do with it. 
  include("../database/connection.php");
  
      $sql1="UPDATE acroom SET status='$_POST[booked]' WHERE roomno='$row[roomno]'";
      // If result matched $myusername and $mypassword, table row must be 1 row
          if(mysql_query($sql1)){
              header("Location:sample.php");
              echo "Records inserted successfully into database.";
  
          } else{
  
              echo "ERROR: Could not able to execute $sql. " . mysql_error($cn);
  
          }
  
  ob_end_flush();
  ?&gt;
  </code></pre>
  
  <p>when i run my browser it show "Records inserted successfully into database" but database not yet to change.
  please help me o resolve my problem.</p>
  
  <p><a href="https://i.stack.imgur.com/x43Dr.png" rel="nofollow noreferrer">enter image description here</a></p>