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.

Sorting

Featured Replies

Hi, I had a fellow do some work to access our database via our web site which has sort of worked but I'm not entirely sure he knew what he was doing, FM API wise, and he is no longer !   Anyway, there's a number of records which are being listed in creation order even though he's apparently put a  sort order (as we had requested), the following seems to be the relevant code.

 

 

# grab search criteria, if any has been sent
    $criteria1 = htmlspecialchars($_POST['refno']);
    $criteria2 = htmlspecialchars($_POST['claimno']);
    $criteria3 = htmlspecialchars($_SESSION['LinkingID']);
    $criteria4 = htmlspecialchars($_GET['type']);
 
# grab the sort column, if any has been sent
    $column = (array_key_exists('column', $_GET)) ? htmlspecialchars($_GET['column']) : '';
 
-
-  a whole bunch of other code, then
-
 
# specify sort column (aka, field), if any
    $request->addSortRule($column, 1);
 
# execute the search transaction
    $result = $request->execute();
 
 
I'm new to php etc ... I don't understand the need for the $column variable, the need for the array_key_exist function and where the 'column' comes into it.  
 
I've tried changing the $request line to   
 
$request->addSortRule('Date',1) --- the Date field being one I want the sort on
 
but it returns an error 
 

thanks

This script is apparently the handler for a form from another file. The other file calls this one with a URL that looks something like  

...yourFile.php?column=Date (there might be some other equations after the ? either before or after this one as well, separated by ampersands [&])

 

The column is fetched in your file by the htmlspecialchars($_GET['column']) function. $_GET is an array that contains the code after the question mark in the url; e.g. column=>Date

 

The $column variable first checks if there is a "column=Date" command in the calling path, and if there is, set the variable to that value.  Otherwise, set $column to no value ('').  It appears that the latter is what is happening, because no sort is performed.

 

You have not provided enough information on the data being passed from the form to know why the field Date is not being read into the array of fields being pulled from the FM file.  This is the reason for the failure, not the code you have presented here.

  • Author

Thanks doughemi

 

there is no 'column' in the parameters being passed just:-

 

cases.php?claimno=123&refno=114577&chk_pass2=Go

 

if I manually type in &column=Date at the end it still doesn't work 

 

is the syntax of the my $request->addSortRule('Date',1) correct ?  .. if so not sure why it's not working  

 

 

might have to find another programmer ! 

Would need the full code of both the original page and the handler page to work out what is going on and how it may be fixed...

is the syntax of the my $request->addSortRule('Date',1) correct ?  

 

Only if the field Date is in the array constructed by the newFindCommand() function.  As webko says, we would need to see both php files to be able to find out.  It sounds to me like it might be a more formidable problem than can be solved on an internet forum.

  • Author

OK, thanks, think I'll stick to the file side scripting and find a new developer for the web side stuff

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.