Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

HurairiDz's avatar

Limit entries in database PHP

Hello ! Need some idea for my small project. I got a student's table with column name and student_id and i want to set the number of entries a user can submit for instance 30 entries.After 30 entries they cannot submit any more data to database.Any idea on how i can approach this?

0 likes
5 replies
rameezisrar's avatar

@hurairidz You have to verify that on the server side. Before inserting into tables, count the entries entered by a specific user(student_id). If they are less than 30 then create/insert the entry else print a error message

HurairiDz's avatar

@RAMEEZISRAR - something like this perhaps?

$res = mysql_query("select count(*) as cnt from user_interests where user_id=$useridint") while($r=mysql_fetch_array($res)) { if($r["cnt"] < 3) { insert } else { error } }

chilitomato's avatar

Put an interests relationship on your Student model and then it's as simple as $count = $student->interests()->count()

Please or to participate in this conversation.