English 中文(简体)
每一用户允许插入的数量
原标题:Limit number of insert allowed per user

当我的网站上有用户标识时,他接着打上显示链接的仪表板。 其中一个链接是add course,其中他认为他可以开办课程......

我想对所有用户使用3门课程的限制,以便所有用户只进入3门课程。 之后,应当发出如下信息:<代码> 到达。

然后他必须选择计划。 我要说的是,我有三项计划: A、B、C

  • A has limit of 10 courses
  • B has limit of 25 courses
  • C has limit of 50 courses

How can I do this?

最佳回答

您可以选择用户迄今为止所开设的课程数目。

为此,您将需要这些课程,以拥有目前用户所特有的东西,通常是使用用户的id。

例如:

SELECT COUNT(user_id) AS numCourses
FROM courses
WHERE user_id = insert_user_id_here

将给您一个包含一个栏的定结果:。 这些课程将包含贵国用户迄今开设的课程数目。

这种希望有助于。

问题回答

这是你能够做到这一点的一种方式。

你们可以为每个用户创造像<条码>选择的计划这样的领域。

否则,该数值可以是default。 计划A可登录<代码>A等。

i want to apply limit of 3 courses insertion by all users

用户在任何时候插入一个课程表,核对该用户的<>条码>和用户插入的课程数目。

类似于

if(selectedplan="default" && courses<=3)
   //add new course
else if(selectedplan="A" && courses<=10)
  //add new course
else
  // "Cannot add more course, limit reached"

计划修改后<代码>选择的计划外地。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签