开发者

Help me with this COUNT query for a php file

$query = 'SELECT COUNT(*) FROM S开发者_如何转开发ecurity WHERE ips=$currentip';

How do i get this to count the $currentip values that i make the variable equal to.


assuming you're using the mysqli function set:

$mysqli=new mysqli('localhost', 'my_user', 'my_password', 'my_db');

$query = 'SELECT COUNT(*) as num FROM Security WHERE ips=$currentip';
$response=$mysqli->query($query);
$row=$response->fetch_assoc();
$count=$row['num'];

It would be preferable to clean $currentip. Or even better to use a prepared statement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜