[FX.php List] FMSkipRecords

DC dan.cynosure at dbmscan.com
Mon Mar 27 10:40:42 MST 2006


Chris,

Reading your explanation of how to implement links with embedded search 
parameters, a small little thought popped into my head...

Aren't the linkNext and linkPrvious array items returned by FX 
implementation dependent (meaning they only work when you use GET) and 
therefore shouldn't they be removed/deprecated from FX since (as you 
indicate) there are many ways to maintain state, search parameters, and 
paging contexts (such as GET, POST, cookies, sessions)?

Also, I believe the approach you describe below of making links into 
FORM elements is a bit abstract. Here's code that shows one way to turn 
a link into a FORM that will allow you to maintain hidden variables in 
the form (requires javascript):

<FORM NAME="sub" METHOD="POST" ACTION="file.php">
<input type="hidden" id="data" name="data" value="mydata">
</FORM>
<a href="javascript:void(0)"
ONCLICK="document.sub.submit(); return false;"
target="_blank">LINK TEXT HERE</a>

This puts a simple form (add hidden elements for any data that you want 
to shepherd into the next form submission) right before the link that 
will use it. Tested in Safari, Firefox (Mac), and IE6.

Cheers,
dan

Chris Hansen had written:
> Jonathan,
> 
> At least part of your problem is that you're mixing the $_GET and  
> $_POST arrays on a page, even though usually only one will contain  
> data.  For example:
> 
> 1) if someone clicks your skip links, the data will be sent via GET  (so 
> elements of the $_POST array will be empty)
> 2) you're pulling data from $_POST['skip'] which would never be  
> populated per (1) above
> 
> I suspect that there's a dynamic search form and you then want to  allow 
> users to browse through paged records.  If that's the case,  here are a 
> couple of pointers:
> 
> 1) Use sessions or hidden inputs to keep track of the current search  
> parameters.  Basically, the solution will need some way to track what  
> the current search is for each user between pages, since your search  
> parameters will not automatically be resent.
> 
> 2) You might consider changing your link so that it submits a form,  
> rather than linking to another page.  That way could could keep track  
> of the search parameters as hidden elements, always submit the page  via 
> POST (since the form method is specified in the form tag), but  still 
> retain the style of your interface.
> 
> HTH
> 
> --Chris Hansen
>   FileMaker 7 Certified Developer
>   Creator of FX.php
>   "The best way from FileMaker to the Web."
>   www.iViking.org
> 
> 
> On Mar 24, 2006, at 12:25 PM, Jonathan Foerster wrote:
> 
>> Hello!
>>
>> I am trying to get the FMSkipRecords function to work.  The code  
>> below fails to return any records (when there should be several  pages 
>> worth).
>>
>> I have stolen much of this code, trying to get something to work  
>> (thanks to you, if you unwittingly contributed).  Thanks!
>>
>> Jonathan Foerster
>>
>> <?php
>> include_once('FX/FX.php');
>> include_once('FX/server_data.php');
>>
>> $Title=$_POST['Title'];
>> $Author=$_POST['Author'];
>> $Year=$_POST['Year'];
>> $Department=$_POST['Department'];
>> $Keywords=$_POST['Keywords'];
>> $Advisor=$_POST['Advisor'];
>> $Records=$_POST['Records'];
>> $Sort=$_POST['Sort'];
>> $Classification=$_POST['Classification'];
>>
>> if(isset($_POST['skip'])){ $skipSize=$_POST['skip'];}else 
>> {$skipSize='5';}
>>
>> $search=new FX($serverIP,$webCompanionPort);
>> $search->SetDBData('FieldStudies.fp7','Entry', $Records);
>> $search->SetDBPassword($webPW,$webUN);
>> $search->AddDBParam('Title',$Title,$operator);
>> $search->AddDBParam('Author',$Author,$operator2);
>> $search->AddDBParam('Year',$Year,$operator3);
>> $search->AddDBParam('Department',$Department);
>> $search->AddDBParam('Description',$Keywords,$operator4);
>> $search->AddDBParam('Advisor',$Advisor,$operator5);
>> $search->AddDBParam('Type',$Classification);
>> $search->AddSortParam($Sort,'ascend');
>> $search->FMSkipRecords($skipSize);
>> $searchResult=$search->FMFind();
>> ?>
>>
>>
>> <table>
>> <tr>
>> <td>
>> <?php
>> if (strlen($searchResult['linkPrevious']) < 1) {
>> ?>
>> &laquo;- Previous
>> <?php
>> } else {
>> ?>
>> <a href="?skip=<?php echo($skipSize) ?>"><strong>&laquo;- Previous</ 
>> strong></a>
>> <?php
>> }
>> ?>
>> </td>
>> <td>
>> <?php
>> if (strlen($searchResult['linkNext']) < 1) {
>> ?>
>> Next -&raquo;
>> <?php
>> } else {
>> ?>
>> <a href="?skip=<?php echo($skipSize) ?>"><strong>Next -&raquo;</ 
>> strong></a>
>> <?php
>> }
>> ?>
>> </td>
>> </tr>
>> </table>
>> _______________________________________________
>> 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