[FX.php List] "Portal" within a "Portal"?

Joel Shapiro jsfmp at earthlink.net
Thu Jul 14 14:26:01 MDT 2005


Thanks Dan, I'll take a good luck at it.

Do you think it's worth creating a join table in FM just for CWP  
purposes, even if it won't be used within FMP?

-Joel


On Jul 14, 2005, at 1:14 PM, DC wrote:

> well... here's a little code i use in situations where there's no time  
> to build a proper join file. It does other things to the FX data array  
> too - including flattening it... so it may not be exactly what you are  
> looking for. basically a little search tool to pluck out one record  
> from a related table returned by FX data array... and the comments  
> inline are the only 'documentation':
>
> http://dbmscan.com/snippets/index.php?cat_select=FX_and_Smarty
>
> look at the "FX nested array to recordset array" entry.
>
> dan
>
> Joel Shapiro had written:
>> Thanks Dan
>> Yes, it's the multiple find requests in a portal that's my sticking   
>> point.  I was thinking that I would not need to create a join file in  
>>  FMP and could just do the joining in PHP (especially since I don't  
>> need  to have any relationships within the FM file to view related  
>> data in  the php).
>> It seems to me that this should work, and I can get it to _kind-of_   
>> work -- getting marks for a specific subject -- but the problem is  
>> that  it's only for the *last* subject for that student's grade (e.g.  
>> If John  has subjects English, History & Science, the php is able to  
>> find just  the Science marks, but it puts them under English and  
>> History as well  -- It doesn't "stop" at each subject, it seems to  
>> loop through and only  capture the last subject.  I think I need a  
>> different ForEach statement  somewhere.
>> I'm put 2 samples of the output here:
>> http://jsfmp.com/php_problem.html
>> Any more thoughts, anyone?
>> TIA
>> -Joel
>> On Jul 14, 2005, at 8:09 AM, DC wrote:
>>> if i understand right, the portal returns multiple data points into   
>>> the data array and you don't think it should. the problem is that  
>>> FMP  can't read your mind and defaults to sending everything in the  
>>> portal.
>>>
>>> confusing the issue is multiple find requests in a portal.
>>>
>>> my advice, do your find request directly on the join file.
>>>
>>> dan
>>>
>>> Joel Shapiro had written:
>>>
>>>> Hi all
>>>> I'm getting better with this, but I'm stuck right now on getting a   
>>>> "portal" within a "portal". This is a school report card project,  
>>>> and  I'd like to have a table that shows all of a student's marks   
>>>> separated by subject. Subjects vary per grade, and each Mark record  
>>>>  contains the subject as well as the student_ID. I can display:
>>>> - All subjects per the student's grade, and
>>>> - All marks per student,
>>>> but when I try to combine them, I can't get the php to 'stop' at  
>>>> each  subject -- instead, I only pull the marks for the last  
>>>> subject for  that student -- even though a print_r shows that the  
>>>> correct subject  is in each row.
>>>> Can anyone give a tip as to what I'm doing wrong?
>>>> Thanks,
>>>> -Joel
>>>> (I've posted my whole page below. Apologies if that's not how this  
>>>> is  done on this list.)
>>>> <?php
>>>> include_once('FX/FX.php');
>>>> include_once('FX/server_data.php');
>>>> include_once('FX/FMErrors.php');
>>>> $recid=$_GET['recid'];
>>>> // THE FOUND STUDENT
>>>> $findstudent=new FX($serverIP,$webCompanionPort);
>>>> $findstudent->SetDBData('school.fp7','Student');
>>>> $findstudent->SetDBPassword('','Admin');
>>>> $findstudent->AddDBParam('-recid',$recid);
>>>> $studentResult=$findstudent->FMFind();
>>>> foreach($studentResult['data'] as $key=>$studentData)
>>>> // ALL SUBJECTS PER STUDENT'S GRADE
>>>> $findsubject=new FX($serverIP,$webCompanionPort);
>>>> $findsubject->SetDBData('school.fp7','Subject');
>>>> $findsubject->SetDBPassword('','Admin');
>>>> $findsubject->AddDBParam('Grade',$studentData['Grade'][0]);
>>>> $subjectResult=$findsubject->FMFind();
>>>> foreach($subjectResult['data'] as $key2=>$subjectData)
>>>> // ALL MARKS PER STUDENT
>>>> $findmark=new FX($serverIP,$webCompanionPort);
>>>> $findmark->SetDBData('school.fp7','Mark');
>>>> $findmark->SetDBPassword('','Admin');
>>>> $findmark->AddDBParam('Student_ID',$studentData['Student_ID'][0]);
>>>> $markResult=$findmark->FMFind();
>>>> // ** PROBLEM: SHOULD BE MARKS PER SUBJECT PER STUDENT **
>>>> $search2=new FX($serverIP,$webCompanionPort);
>>>> $search2->SetDBData('school.fp7','Mark');
>>>> $search2->SetDBPassword('','Admin');
>>>> $search2->AddDBParam('Student_ID',$studentData['Student_ID'][0]);
>>>> $search2->AddDBParam('Subject',$subjectData['Subject'][0]);
>>>> $search2Result=$search2->FMFind();
>>>> ?>
>>>> <html>
>>>> <head>
>>>> <title>School</title>
>>>> </head>
>>>> <body>
>>>> <B><?php echo $studentData['Name'][0]; ?></B> Grade: <?php echo   
>>>> $studentData['Grade'][0]; ?><BR>
>>>> ** ALL SUBJECTS PER STUDENT'S GRADE **
>>>> <table border="1" cellpadding="2" cellspacing="0"   
>>>> bordercolor="#999999">
>>>> <tr>
>>>> <td>Subjects for Grade <?php echo $studentData['Grade'][0]; ?></td>
>>>> </tr>
>>>> <?php foreach($subjectResult['data'] as $key=>$subjectData) { ?>
>>>> <tr>
>>>> <td><?php echo $subjectData['Subject'][0]; ?></td>
>>>> </tr>
>>>> <?php } ?>
>>>> </table><BR>
>>>> ** ALL MARKS PER STUDENT **
>>>> <table border="1" cellpadding="2" cellspacing="0"   
>>>> bordercolor="#999999">
>>>> <tr>
>>>> <td>Mark_ID</td>
>>>> <td>Mark</td>
>>>> <td>Subject</td>
>>>> <td>Student_ID</td>
>>>> </tr>
>>>> <?php foreach($markResult['data'] as $key=>$markData) { ?>
>>>> <tr>
>>>> <td><?php echo $markData['Mark_ID'][0]; ?></td>
>>>> <td><?php echo $markData['Mark'][0]; ?></td>
>>>> <td><?php echo $markData['Subject'][0]; ?></td>
>>>> <td><?php echo $markData['Student_ID'][0]; ?></td>
>>>> </tr>
>>>> <?php } ?>
>>>> </table><BR>
>>>> ** PROBLEM: ALL MARKS PER PER SUBJECT PER STUDENT **
>>>> <table border="1" cellpadding="2" cellspacing="0"   
>>>> bordercolor="#999999">
>>>> <tr>
>>>> <td>Subjects for Grade <?php echo $studentData['Grade'][0]; ?></td>
>>>> </tr>
>>>> <?php foreach($subjectResult['data'] as $key=>$subjectData) { ?>
>>>> <tr>
>>>> <td><?php echo $subjectData['Subject'][0]; ?></td>
>>>> </tr>
>>>> <!-- **** PROBLEM: Only pulls last Subject in array, not one  
>>>> ForEach  **** -->
>>>> <?php foreach($search2Result['data'] as $key=>$search2Data) { ?>
>>>> <tr>
>>>> <td>
>>>> <?php print_r ($subjectData['Subject'][0]); ?><BR>
>>>> <?php echo $search2Data['Mark_ID'][0]; ?>
>>>> </td>
>>>> <td><?php echo $search2Data['Mark'][0]; ?></td>
>>>> <td><?php echo $search2Data['Subject'][0]; ?></td>
>>>> <td><?php echo $search2Data['Student_ID'][0]; ?></td>
>>>> </tr>
>>>> <?php } ?>
>>>> <!-- **** END PROBLEM **** -->
>>>> <?php } ?>
>>>> </table>
>>>> </body>
>>>> </html>
>>>> -------------------------------------------------------------------- 
>>>> -- --
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>



More information about the FX.php_List mailing list