Forum Moderators: coopster

Message Too Old, No Replies

Can I put a cap on the number of records added?

for various members of a member website

         

mcjohnson

1:58 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



This one is a new one for me. Is it possible to limit the number of records any one "member" is able to add to the MySQL db?

In other words, basic members are entitled to add 50 items, but premlium members 100 items.

Has anyone ever heard of or done this?

Mcj

interactive gun

5:24 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



you can do it with php call out your primary, and create another table with the primary plus count (in your case 50 or 100 per user). so your table might look like:
_user__(primary) __qty__
Then you can do a sum on just one page, or all of them as an include "SELECT SUM(qty) AS name_of_count FROM ..." if it is up to 50 block the user from adding more.

or

do a count before entering into db, and if result is higher than 50 send them back, or to another page.
$qty_rows=mysql_num_rows($qty_rows_result);
if ($qty_rows>50) {go back}else {insert in DB and go forward.}

depending upon what site you run, it is necessary in many cases.

ergophobe

5:42 pm on Feb 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just do a query along the lines that interactive outlined and find out how many items they have and then make the "Add Item" link active or not depending.

<p><a href="add.php">Add Item</a> (you may add up to 23 more items)</p>

or, if they have reached quota

<p>Sorry, you can't add any additional items. You've reached your quota of 100 items</p>

Then, of course, you need to check when the add.php page is invoked that the user is logged in and has additional space in the quota before presenting a form.

If you need help with the specific query, post a *few* details on how the user and items tables are related and how the data is stored.