Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Altering a field name with a counter variable

Featured Replies

I have a table with a large number of records (research participants). Based on their responses to a set of screening questionnaires, they are eligible for 0-5 additional research studies. The research studies are in a related table("studies") containing the name of each study and the eligibility criteria. For each subject in the big table, there are 5 variables, eligible1...eligible5, that are set to either 1 or 0 by a script that evaluates whether the subject has qualified for each one of the 5 studies.

Below is the code that inserts a portal into my php page. As written, it displays all 5 studies. I want it to display only the studies for which the participant is eligible. My idea was to use if statements for each portal row that are based on whether the "eligible" variable corresponding to that row is 1 or 0.

Is there a way to specify a variable name by concatinating a field name and an index variable? In other words, does php allow me to create "if eligible1 = 1" with code like "if eligible{portal_rownum} = 1" where portal_rownum will be substituted out for it's value to create "eligible1" or 2 or 3 etc.

I know nothing about php but have been enabled to a dangerous degree by FMStudio (which rocks!).

TIA

<?php echo array_shift(explode('.',$switchback_row_key)); ?>

<?php

$switchback_studies_portal_rownum = 1;

foreach($switchback_row['studies::study_name'] as $switchback_studies_portal_row=>$switchback_studies_portal){ 

?>

  

    

      �

      hi

    

      

  <?php if($switchback_studies_portal_rownum == 10) break; else $switchback_studies_portal_rownum++;

}//portal_end ?>

I'm not a PHP expert by any means, but if I understand correctly what you want, maybe this can help:

$portal_rownum = 1;

$eligible = "eligible".$portal_rownum;

$$eligible (note the two dollar signs) will give you a variable named "eligible1" which you can use in your conditional statement.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.