How to get the result of a select count(*) query in PHP?

前端 未结 10 1213
离开以前
离开以前 2021-02-03 10:49

I have this query to use in PHP:

mysql_query(\"select count(*) from registeredUsers where email=\".$_SESSION[\"username\"]);

When I use e

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-03 11:19

    $resultemp = mysql_query("select count(*) AS count from registeredUsers where email='{$_SESSION['username']}'");
    
    // Verify mySQL Query Rresult
    
    if (!$resultemp) echo mysql_error();
    
    // Convert mySQL Result for PHP
    
    $counter=mysql_fetch_assoc($resultemp);
    $counter=$counter['count'];
    
    // Print Total Employees
    
    echo $counter;
    

提交回复
热议问题