Last active
June 26, 2017 06:27
-
-
Save FelipeGrijo/86d8f0cf496defa4910d8fc70a67f943 to your computer and use it in GitHub Desktop.
Contar quantidade de ids de um banco de dados usando mysqli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://gist.github.com/FelipeGrijo | |
$host = 'localhost';//Endereco | |
$user = 'root';//Usuario | |
$pass = '';//Senha | |
$db = 'contas2';//Nome do banco de dados | |
$mysqli = new mysqli($host,$user,$pass,$db); | |
$sql="SELECT count(id) AS total FROM usuarios";//usuarios = nome da tabela | |
//$sql="SELECT count(id) AS total FROM usuarios where ativo='0'"; | |
$result=mysqli_query($mysqli,$sql); | |
$values=mysqli_fetch_assoc($result); | |
$num_rows=$values['total']; | |
echo $num_rows; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment