title: update and delete data from a MySQL Database table
body: <p>I have a DB table. i want to update and delete data from that table. I am new in php and MySQL. I tried but can't work. can anybody help me, please?????
  My code is bellow:</p>
  
  <p><strong>For Update------------</strong></p>
  
  <pre><code>&lt;table border = "1"&gt;
          &lt;tbody&gt;
              &lt;caption&gt;
                  Update or Delete your event.                
              &lt;/caption&gt;
              &lt;tr&gt;
                  &lt;th&gt;No&lt;/th&gt;
                  &lt;th&gt;Message&lt;/th&gt;
                  &lt;th&gt;Update/Delete&lt;/th&gt;
              &lt;/tr&gt;
              &lt;?php 
                  while ($row = mysql_fetch_array($sqldata)) {
                      ?&gt;
                  &lt;tr class="grey"&gt;
                      &lt;td class="no"&gt;1&lt;/td&gt;
                      &lt;td class="message"&gt;&lt;?php echo $row['message']; ?&gt;&lt;/td&gt;
                      &lt;td class="button"&gt;
                          &lt;a href="editevent.php"&gt;&lt;input type="button" name="update" value="Update"&gt;&lt;/a&gt;
                          &lt;input type="button" name="delete" value="Delete"&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;tr class="white"&gt;
                      &lt;td class="no"&gt;2&lt;/td&gt;
                      &lt;td class="message"&gt;&lt;?php echo $row['message']; ?&gt;&lt;/td&gt;
                      &lt;td class="button"&gt;
                          &lt;a href="editevent.php"&gt;&lt;input type="button" name="update" value="Update"&gt;&lt;/a&gt;
                          &lt;a href="delete.php"&gt;&lt;input type="button" name="delete" value="Delete"&gt;&lt;/a&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
  
              &lt;?php
                      break 1;
              }
               ?&gt;
          &lt;/tbody&gt;        
      &lt;/table&gt;
  </code></pre>
  
  <p><strong>For Delete:--------------</strong></p>
  
  <pre><code>&lt;?php 
  
      $id = $_GET['id'];
  
  
      $delete = "DELETE FROM calendar_event WHERE id='".$id."'";
  
      mysql_query($con,$delete);
      mysql_close($con);
  
   ?&gt;
  </code></pre>
  
  <p>Codes are not appropriate. please, anybody give me a correct code.</p>