I’ll start by putting my finger on what I think is wrong.
What reason would anyone have to show only the amount of registrants?
I think I’m wrong.I think I want to count users with a given name if it is : "IS WRONG"
$sql = "SELECT * FROM usuarios";
$query = mysql_query($sql);
$conta = mysql_num_rows($query);
If I’m right, you’ll have some discretion to tell me... "CORRECT"
Put one in your html
<div id="user"></div>
and a field responsible for rescuing its criteria
<input type="text" placeholder="Digite o nome da cidade"name="Campo" id="Campo" onchange="PgReal(this.value);/>
The function is executed OnChange
When you change the value of the E field you will return the values :
Pay attention to that = php? Field file name
$variavelCampoNome=$_GET['CampoNome'];
$sql = "SELECT * FROM usuarios WHERE `Coluna` LIKE '%$variavelCampoNome%'";
if ($Resultado = mysql_query($sql)){ // Se ele conseguir executar
$conta = mysql_num_rows($Resultado);//faz a contagem
if ($conta==0){ //se FOR IGUAL A ZERO
echo 'Nenhuma Informação encontrada com esse criterio';
}else{ //Mostra a quantidade SE FOR DIFERENTE DE ZERO
echo '<span id="users">.$conta</span>';
while($Linha = mysql_fetch_array($Resultado)) {
//Criterios para exibir
$VariavelColuna=$Linha[ColunaExibir];
echo $VariavelColuna;
}
}
Now the function .
function PgReal(str) {
if (str == "") {
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("user").innerHTML = this.responseText; //Copia a resposta Para o div id=user
}
};
xmlhttp.open("GET","Arquivo.php?CampoNome="+str,true);//Exececuta o chamado usando o valor do campo que você colocou o botao ONCHANGE
xmlhttp.send();
}
}
I THINK THAT’S WHAT YOU REALLY WANTED. MORE INTERNET FOR THIS.
EDIT HOW AND WHERE YOU FIND BEST! Good luck
You will need a real-time database, which is not the case with Mysql, search for Firebase, must meet your needs
– Woton Sampaio
Could use Ajax requesting seconds to seconds.
– Sam
Well, I meant using ajax... but I don’t know how I can do this
– Gustavo Gbn