i have this html form <form action="insert.php" method="post"> ko: <INPUT NAME="ko" SIZE=7 MAXLENGTH=20 onKeyPress="return numbersonly(this, event)"> <input type="submit" /> </form> HTML: Then i have this php code <? include "config.php"; ?> $sql="INSERT INTO bokning (ko) VALUES ('$_POST[ko]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "X record added"; mysql_close($con) ?> PHP: let's say the limit for "ko" is set to 3 in the database(Table named "admin", collumn named "komax") and someone enters 5 into the form and presses submit, before it's enterd into the database, how can i make it sum up every row for "ko" in the table, "bokning" and give an error if it exceeds the limit of "komax" ?