1
I’m trying to make a table with radio that when I click, changes the order that is displayed the table content, I saw that the way to do this is with ajax, but I do not have much time left, and from what I saw in ajax I could not understand to use this. If someone can help me show how an ajax function that sends the value from inside a radio to php on the same page without giving refresh, thank you very much, just missing this for the end of my tcc (high school), and I do not understand anything ajax. follows below the ajax function and my failure to try to make 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;
}
this #listing would serve what? and in my case php is on the same page as the table. so much so that it is giving Undefined index error in mode.
– Pedro H Ferreira
It cannot be on the same page, it has to be on another separate page, for ajax to call the page in the correct way and display..
– Sr. André Baill
but if I put the whole php part on another page as I would for it to receive the variable that is sent to the html page? with include would work normal?
– Pedro H Ferreira