更改表的单元格值

I want to change cell value of table when click on that value. Default value of that cell is '0'. When I click on that I want change it to '1' and '1' to '0'. I'm new for web developing.

If any one can help it will be highly appreciated.

    # Init the MySQL Connection
  mysql_connect("localhost", "root", "") or die(mysql_error()) ; 
 mysql_select_db("selfie") or die(mysql_error()) ; 

 # Prepare the SELECT Query
  $selectSQL = 'SELECT * FROM `image_upload` INNER JOIN user_table
ON image_upload.user_id=user_table.user_id ORDER BY timestamp DESC';
# Execute the SELECT Query
  if( !( $selectRes = mysql_query( $selectSQL ) ) ){
    echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();
  }else{
?>
<table border="2">

  <thead>
    <tr>
      <th>User name</th>
      <th>Category</th>
      <th>Description</th>
      <th>Image</th>
      <th>Location</th>
      <th>Status</th>
    </tr>
  </thead>
  <tbody>
    <?php
      if( mysql_num_rows( $selectRes )==0 ){
        echo '<tr><td colspan="4">No Rows Returned</td></tr>';
      }else{
        while( $row = mysql_fetch_assoc( $selectRes ) ){
          echo "<tr>
          <td>{$row['user_name']}</td>
          <td>{$row['category']}</td>
          <td>{$row['description']}</td>
          <td ><img src='uploads/".$row['image']."'width=300px height=200px></td>
          <td>{$row['location']}</td>
          <td>{$row['flag']}</td>

   </tr>
";
            }
      }
        ?>
     </tbody>
    </table>
<td onclick = "this.innerHTML=Math.abs(parseInt(this.innerHTML) - 1);">0</td>
$("td").click(function(){
  value = parseInt($(this).text());
  value = (value > 0)? 0 : 1;
  $(this).text(value);
});

That's it.

In jQuery i would do this as this

$('.target').click(function () {
    var target = $('.target').html();
    if (target == 0) {
        $('.target').html(1);
    }
    if (target == 1) {
        $('.target').html(0);
    }
})

when in html the target td is classed with "target"

fiddle here