This topic is locked

Disable 'Add New' button on VIEW pages conditionally

6/9/2009 8:22:08 PM
PHPRunner General questions
D
DigitalDean8 author

I have a project with a master table "cartype" and a child table "reviews". I only want to allow each user to post one review for each kind of car and also only if their GroupID matches a specific value. So what I would like to do is on the VIEW page of the cars table conditionally show/hide a custom "Add New Review" button to that page based on if that username has previously posted a review for that car. Obviously this involves both a lookup and a conditional display/or activation of an Add button.
any idea on how to accomplish this? A code snippet would be highly appreciated.

J
Jane 6/11/2009

Hi,
use List page: Before display event on the Events tab for this purpose.

Here is just a sample:

$rs = CustomQuery("select count(*) from reviews where Username='".$_SESSION["UserID"]."'");

$data = db_fetch_numarray($rs);

if ($data[0]>1)

$xt->assign("add_link",false);

else

$xt->assign("add_link",true);