-1

I want these functions to execute when javascript code executes;

function check_count2($userid,$picid){
 $sql5 = "select count(*) from abctable 
   where persona='$kuladii123' and personb='$resimid'";
 $result5 = mysql_query($sql5);

 $row5 = mysql_fetch_row($result5);
 return $row5[0];

}

function myfunction($userid,$picid){
 $test = check_count2($userid,$picid);

 if ($test == 0){
  $sql6 = "insert into abctable (persona,personb) 
    values ($userid,$picid)";

  $result6 = mysql_query($sql6);
 }
}

Javascript code;

<script type="text/javascript">
  
$(".photos'.$picid.'").waypoint(function() {       

         myfunction(); // I WANT THIS FUNCTION HERE!

        }
});

</script>

I can't call myfunction, please help me.

Cuba Libre
  • 35
  • 4

1 Answers1

0

To execute a php function with javascript you need AJAX. You'll need to create an ajax call to a php file which executes the function.

$.ajax({
    url: "yourphpfile.php"
}).done(function() {
    $( this ).addClass( "done" );
});
Xposedbones
  • 597
  • 4
  • 7