Call a PHP function using a button

<?php function AjoutNote() { echo "

dedans la sub

"; } function AfficherNoteS() { $cn=mysql_connect("localhost","root",""); if(!$cn) { echo "Impossible de se connecter : " . mysql_error(); } $db_Inventaire=mysql_select_db('Inventaire',$cn); if(!$db_Inventaire) { echo "Impossible d'utiliser la base : " . mysql_error(); } $query="select * from Notes"; $result=mysql_query($query); $nb=mysql_numrows($result); $i=0; echo "
"; $note=mysql_result($result,$i,"DescNote"); echo "La Note No " . ($i+1) . " " . $note; $i++; echo "
"; } ?> <form> <button type="submit" name="btAdd" value="Ajouter une Note" onclick="AjoutNote();">Ajouter une Note</button> <button type="button" name="btAfficher" value="Afficher les Notes" onclick="&lt;? AfficherNoteS() ?&gt;">Afficher les Notes</button> </form>

1 answer

  • Votes
  • Date
  • Descending date
  1. Hello,
    Since PHP acts ONLY on the server side it is impossible to use only PHP for that.
    We can use AJAX:
    A short tutorial: https://www.xul.fr/xml-ajax.html