This topic is locked

Limit Number of entries per user; in another table by variable in anot

8/29/2011 7:42:02 AM
PHPRunner General questions
C
cleanroomdesign author

I have a field named quanity that is populated from a paypal ipn with a quanity. That Number becomes a variable assigned to a user that limits the number of records he can enter into table recipients.
I currently enter that quanity of records with NULL in all fields except for ownid (which is linked to id in table mydetails)

I would prefer that the user just be able to add records until the limit is reached, then the add button should disappear.
is this possible?
More along the same line

also poplulated from the paypal ipn are the fields cosponsor and clients

if the cosponsor field is 1 or yes i want to automatically add one record to the cosponsor table and give user edit permissions.

if the clints field is 1 or yes, then the user should have add edit delete permissions to that table. If it is not checked he should not see anything and same with clients.
Below is my feeble attempt. Please help!

<?php
//Define the max entries allowed

$value = $data["recipients"];
$res=$value;
$res=mysql_query('SELECT recipients FROM mydetails WHERE id = $userid') or die(mysql_error());

$totalrecords=mysql_num_rows($res);

if($totalrecords<=$res)

{ allow insert}

else {remove buttons}
?>

<?php
//Did user buy clients?

$value = $data["clients"];

$res=$value;

$res=mysql_query('select clients from mydetails where id = $userid') or die(mysql_error());

$result=$res;

if($res='1')

{ allow insert}

else {remove buttons}
?>

<?php
//Did user buy cospsonsor?

$value = $data["cospsonsor"];

$res=$value;

$res=mysql_query('SELECT cosponsor FROM mydetails WHERE id = $userid') or die(mysql_error());

$totalrecords=mysql_num_rows($res);

if($totalrecords<=$res)

{ allow insert}

else {remove buttons}
?>

Sergey Kornilov admin 8/29/2011

Not quite sure where you want to apply this code.
For example, if you want to hide 'Save' button on the Add page you can add the following code to Add page BeforeDisplay event:

$xt->assign('save_button',false);