title: calling a php function in javascript
body: <p>I dont know how to use ajax in my problem:
  I have a function in php (assign) that update a temporary table in database, I want to when user user click on a button (feedback function that is defined in javascript) this function (assign) run, what should I do?</p>
  
  <pre><code>   &lt;script&gt;
  
         function feedback(){
              var boxes = document.getElementsByClassName('box');
              for(var j = 0; j &lt; boxes.length; j++){
                  if(boxes[j].checked) {
                      assign(1);
                  }
                  else{
                      assign(0);
                  }
              }
          } 
  
     &lt;/script&gt;
  
  
  
  
    &lt;?php
          $con = mysql_connect("localhost", "root", "")
          or die(mysql_error());   
          if (!$con) { 
              die('Could not connect to MySQL: ' . mysql_error()); 
          } 
          mysql_select_db("project", $con)
          or die(mysql_error());
          $result = mysql_query("select * from words");
          echo "&lt;table border='1'&gt;
             &lt;tr&gt;
                &lt;th&gt;word&lt;/th&gt;
                &lt;th&gt;meaning&lt;/th&gt;
                &lt;th&gt;checking&lt;/th&gt;
              &lt;/tr&gt;";
              while($row = mysql_fetch_array($result)) {
                    echo "&lt;tr&gt;";
                      echo "&lt;td&gt;" . $row['word'] . "&lt;/td&gt;";
                      $idd= $row['id'] ;
                      echo "&lt;td&gt;". "&lt;div class='hiding' style='display:none'&gt;".$row['meaning']."&lt;/div&gt;"."&lt;/td&gt;";
                      echo "&lt;td&gt;";
                       echo "&lt;input class=\"box\" name=\"$idd\" type=\"checkbox\" value=\"\"&gt; ";
                      echo "&lt;/td&gt;";
                    echo "&lt;/tr&gt;";
                    }
           echo "&lt;/table&gt;";
  
                  function assign($checkparm){
  
                        //mysql_query("update words set checking=$checkparm ");
                         mysql_query("create TEMPORARY TABLE words1user1 as (SELECT * FROM words) ");         
                         mysql_query("update words1user1 set checking=$checkparm ");
  
                                        }
  
           mysql_close($con);                        
          ?&gt;
          &lt;button onclick="ShowMeanings()"&gt;ShowMeanings&lt;/button&gt;
          &lt;button onclick="feedback()"&gt;sendfeedback&lt;/button&gt;  
  </code></pre>