What is the difference between using COUNT(typeid) and COUNT(*) in a SQL query in PHP?

When using COUNT(typeid), the query will only count the rows where the typeid column is not null. On the other hand, using COUNT(*) will count all rows, regardless of whether the typeid column is null or not. Therefore, if you want to count all rows in a table, including those where the typeid column is null, you should use COUNT(*).

// Using COUNT(*)
$query = "SELECT COUNT(*) FROM table_name";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$count = $row[0];
echo "Total rows: " . $count;