php - How to check if string exists in more than X rows -


i know if following possible, , how:

i want check if username in table appears in 5 or more rows

my table:

enter image description here

example of usage want:

if name (teste) on more 5 rows something..

use having, allows filter aggregated / manipulated fields

select count(username) shows_counter tbl  group username  having count(username)>5   $check = mysql_query("select count(name),name  hack_log group name having count(name)>5");   $check = mysql_num_rows($result);// **add row**  if($check){ echo "hacker!"; }else{ echo "not hacker"; } 
  • please use pdo or mysqli build-in objects

accorging needs

you need check number of rows

    $db = new pdo('mysql:host=your_hostname;dbname=your_db;charset=utf-8', $user, $pass);     $q = $db->prepare('select count(name),name      hack_log group name having count(name)>5');     $q->execute();     $rows = $q->fetchall();     $res= count($rows)>0?"hacker":"no hacker";     echo $res; 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -