PHPR 5.3 build 7474
I have 2 tables: a function table with fields concerning the function details (Venue, Date, Time etc.) then I have a RSVP table which stores every function's attendees' details.
I added extra fields to the function table so the registered user can choose(checkboxes) which fields they want people to fill in. This should then manipulate the SQL query($gSqlHead of the RSVP table) so that certain columns in the RSVP table isn't shown for the particular function.
I want to do this because every function needs different details from the RSVP person.(weddings, corporate etc.)
So the RSVP table has all the fields that any function should require for RSVP purposes, but I need to hide the fields that isn't chosen by the registered user.
I tried the following code in the after table initialized event of the RSVP table, but it didn't work:
NOTE: functions is the master table, and the child table is RSVP.
if($_REQUEST["masterkey1"])
{
$BuildSql="SELECT ";
$sql="SELECT * from functions where FunctionID = ".$_REQUEST["masterkey1"];
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
if ($data["FieldName"]) //Checks if registered user has ticked the Name field in the functions table
$BuildSql.="Name,"; //If checked, add Name, to the string
if ($data["FieldSurname"])
$BuildSql.="Surname,";
if ($data["FieldGender"])
$BuildSql.="Gender,";
substr($BuildSql,0,-1);//to remove the last "," from the string
}
$gsqlHead=$BuildSql;
Any suggestions to what I'm doing wrong, or do someone know about a suitable workaround? Or does PHPR not support this type of functionality?
I know how to hide the fields on the add, edit and view pages(hidediv), but I also need to hide it on the list page, and this I can't seem to get to work.
Any help would be much appreciated.