View Data From Multiple Section Files

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 14, 2011   (RSS)

By nmsinc - September 9, 2011

I have three sections that are used to populate a fourth section. When the record is saved in the fourth section it saves only the file number from each of the other sections that are chosen, therefore, viewing the list or detail page only the file number shows up.

Is there a way to show information from the other three sections that correspond to their respective file numbers for each record saved in the fourth section?

Thanks - Ray
nmsinc

Re: [nmsinc] View Data From Multiple Section Files

By Jason - September 14, 2011

Hi Ray,

What you'll have to do is do a separate database query for each of the other sections. If you're using CMSB version 2.08 or higher, you can use this example.

Assume that the record from your fourth section is being stored in a variable called $record. Assume that the other three tables are called 'table1', 'table2', and 'table3' and that $record has fields called table1, table2, and table3 that correspond to record numbers in those tables.

We can get the three other records like this:


$table1Record = mysql_get('table1', $record['table1']);
$table2Record = mysql_get('table2', $record['table3']);
$table3Record = mysql_get('table3', $record['table3']);


The data in each of these 3 records are now stored in $table1Record, $table2Record, and $table3Record, respectively.

It's important to note that this method will not return any uploads, or any pseudofields like :label or :text.

Hope this helps. let me know if you run into any issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/