I'm trying to make a table with a radio that when I click, it changes the order that the contents of the table is displayed, I saw that the way to do this is with ajax, but I do not have much time remaining, and from what I saw ajax I could not figure out how to use it. if someone can help me to show how it would look like an ajax function that sends the value from within a radius to the php on the same page without giving refresh, thank you very much, just missing it for the end of my tcc (high school), and I do not understand anything about ajax. follows the ajax function below and my failed attempt to make the radios change the value of $ mode.
echo "<form name='busca' method='GET' >";
echo "<table><tr><td>";
echo "<input type='radio' checked name='modo' value='0' onSelect=" $modo = 0; ">Mais curtidos</td><td>";
echo "<input type='radio' name='modo' value='1' onSelect=" $modo = 1; ">Menos curtidos</td></tr><td>";
echo "<input type='radio' name='modo' value='2' onSelect=" $modo = 2; ">Mais novos</td><td>";
echo "<input type='radio' name='modo' value='3' onSelect=" $modo = 3; ">Mais antigos</td></tr>";
echo "</table>";
switch($modo){
case "0":
$varsql = "SELECT * FROM $tab WHERE TIPO='$tipo' ORDER BY likes DESC";
break;
case "1":
$varsql = "SELECT * FROM $tab WHERE TIPO='$tipo' ORDER BY likes ASC";
break;
case "2":
$varsql = "SELECT * FROM $tab WHERE TIPO='$tipo' ORDER BY id DESC";
break;
case "3":
$varsql = "SELECT * FROM $tab WHERE TIPO='$tipo' ORDER BY id ASC";
break;
}