Answer the question
In order to leave comments, you need to log in
How can I get from the database the number of records in which the list value is equal to element 1?
Hello. I'll try to explain more clearly. There is a database, it has a table with records. Each entry contains a value from the list - 1, 2 or 3. I connected to the database and got the total number of entries in the table:
$sql = "SELECT * FROM cms_con_ls";
if($result = $conn->query($sql)){
$rowsCount = $result->num_rows;
Answer the question
In order to leave comments, you need to log in
In general, he did.
$conn = new mysqli("localhost", "пользователь", "пароль", "база");
$alls = $conn->query("SELECT COUNT(*) FROM cms_con_ls WHERE status=1");
$row = $alls->fetch_row();
$allso = $row[0];
echo $allso;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question