开发者

Help me with this COUNT query for a php file

开发者 https://www.devze.com 2022-12-27 06:35 出处:网络
$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

$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

精彩评论

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