I have a table with several records, and let's say that each one collects the visits it has (for example). How can I get the total of visits?
But not of all, but of those who fulfill a condition. That is, if I have:
| Cat | Visitas |
-----------------------
| Juegos | 12 |
| Juegos | 7 |
| Programas | 23 |
How do I get the sum of visitas
of all records whose entry is Juegos
?
At the moment, the only thing I have done is the mySQL connection:
$conn = mysqli_connect($servername1, $username1, $password1, $dbname1);
$reg = mysqli_query($conn,
"SELECT * FROM posts WHERE cat='$cat'")
or die( "Error al conectar con la base de datos 2: " . mysqli_error($conn) );
Thank you very much.