system pointing with update sql

`Hello everyone,
I am a beginner in php development. I am looking for a solution to clock the presence of my members in javascript, and at the same time update my table based on the id.

Here’s what I started doing:

_ 2 requests:

$present=update_examination_present($EXAM_id);

$absent=update_examination_absent($EXAM_id;

_ Button of my table:

`<td><INPUT type=”button” class=”btn btn-warning” title=”Pointing of <?php echo $list_pgChildren[$a][‘ADHE_nom’].” “.$list_pgChildren[$a][‘ADHE_prenom’]; ?>” value=”POINTAGE” onclick=”myFunction(this);pointage(a)”></INPUT> <?php`your text` } elseif($list_pgChildren[$a][‘EXAM_present’]==1) { ?> <INPUT type=”button” class=”btn btn-success” title=”Modifying <?php echo $list_pgChildren[$a][‘ADHE_nom’].” “.$list_pgChildren[$a][‘ADHE_prenom’]; ?>” value=”PRESENT” onclick=”myFunction(this)”></INPUT> <?php } ?>`

_ my script which works with my “INPUT type=button”:

<script language="JavaScript" type="text/javascript">function myFunction(anObject){ if (anObject.value == "POINTING"){ //alert('I'm doing this'); anObject.value = "PRESENT"; }else { //alert('I do this'); anObject.value = "POINTAGE";}}</script>

I would like to integrate my 2 requests into the script:

_ if I click the first time on my “POINTAGE” button, it executes my “$present” query and displays “PRESENT” on my button.

_ if I click again on this same “PRESENT” button, it executes my “$absent” query and displays “POINTAGE” on my button.
Can you help me please?