This topic is locked

Hide custom button on list page depending on record in other table

8/26/2023 3:23:52 PM
PHPRunner General questions
author

I have a list page and I added a custom button "Enroll" that will be showed for each record on the list page.
When someone presses the button, a new record is saved to a table called "Enrollment", saving UserID and EventID
Now, each time the page is loaded, I want the hide the buttons for the events that already have an enrollment record in the jenrollment table.
I tried the "After record process" event where i did this:
$sql= "SELECT * FROM Enrollement WHERE EVENTID='"
.$data['id_event']
."' AND lidID='"
. $_SESSION['IDUSER']
. "'";
$rs2=DB::Query($sql);
$records= $rs2->fetchAssoc();
if($records)
{
$pageObject->hideItem("custom_button");
}
else
{
}
The problem is with the selection of my id_event... whenever there is a record in the table, all buttons are hidden...so I'm guessing the problem i have is with getting that Event_ID , related to each row.
ANyone?

502103 8/26/2023

Solved it, had to use:
$pageObject->hideItem("custom_button", $recordId);