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.
精彩评论