I am trying to count how many records in a mysql db using a query with a where condition. Unfortunately, the code I am using is not producing any results.
If i enter the query directly into myphpadmin, it shows there are 78 records. I am confused as to why it is not working. I would be grateful if someone could point out my error. Many thanks
<?php
$result1 = mysqli_query("SELECT count(*) FROM act WHERE activity = 'New Intake' AND new = '1'");
$rows = mysqli_fetch_row($result1);
$num = $rows;
?>
1.
connectionlink is missing in query.(first parameter).2.Use alias inside query.
3.Assign counted value to varibale.
4.
echothe variable to see the result.Do like below:-
Note:- Your code is wide-open for SQL INJECTION.You have to use
prepared statementsHelp reference:-
mysqli::prepare
PDO::prepare