Jump to content




Can't get FMSkipRecords to work correctly



  • Please log in to reply
1 reply to this topic

#1 OFFLINE   LFFMHelp  newbie

LFFMHelp
  • Members
  • PipPipPip
  • 3 posts
  • FM Client:6.5
  • Platform:Mac OS X Panther
  • Skill Level:Intermediate
  • Time Online: 4h 27m 34s

Posted 22 February 2012 - 08:43 AM

I'm attempting to use a form to allow users to narrow/filter results when searching our tech request system because we have quiet a few entries in our database. I'm hoping to return 15-20 requests per page and allow the user to use the FMSkipRecord feature to navigate through their returned results sorting the returned results by date/time modified. However when I perform a search that yields more than 15 results and click "next" the page loads a records found: 0, Displaying Records 1 through 0 result.

Here is the code:

<?php

// Inialize session
session_start();

// Value(s) from search_request.php
$completed = $_POST['completed'];
$database = $_POST['database'];
$lastname = $_POST['lastname'];
$description = $_POST['description'];
$school = $_POST['school'];
$problem = $_POST['problem'];
$assigned = $_POST['assigned'];

//Find number of records to skip and set Groupsize
if (! isset($skip) || $skip == '') {$skip = 0;}
if (! isset($FXE_groupSize) || strlen(trim($FXE_groupSize)) == 0) $FXE_groupSize = 15;

$query = new FX($serverIP, $webCompanionPort, $dataSourceType);
$query->SetDBData ("$database", "Main", "$FXE_groupSize");
$query->FMSkipRecords($skip);
$query->SetDBUserPass ($webUN, $webPW);
$query->AddDBParam('Completed?', $completed,'eq');
$query->AddDBParam('Last', $lastname, 'cn');
$query->AddDBParam('Description', $description,'cn');
$query->AddDBParam('School', $school,'eq');
$query->AddDBParam('Type', $problem,'eq');
$query->AddDBParam('Assigned_to', $assigned,'eq');
$query->AddSortParam ('Date Modified','descending'); // Sort by Date Modified
$query->AddSortParam ('Time Modified','descending'); // Sort by Time Modified
$result = $query->FMFind();
$records = $result['data'];
?>

In the HTML body:

<?php

echo '<p class="indent">Records Found: ' .$result['foundCount'].'</p>';
echo '<p class="indent">Displaying Records ' . ($skip + 1) . ' through ' . min(($skip + $FXE_groupSize), $result['foundCount'].'</p>');
echo '<br />';

if (strlen($result['linkPrevious']) < 1) {echo "<span class=\"medgraytext\">Prev</span>\n";}
else {echo '<a href="'.$result['linkPrevious']."\" class=\"bbody\">Prev</a>\n";}

if (strlen($result['linkNext']) < 1) {echo "<span class=\"medgraytext\">Next</span>\n";}
else {echo '<a href="'.$result['linkNext']."\" class=\"bbody\">Next</a>\n";}

foreach ($result['data'] as $key => $value) {

// Begin the Search Table

echo '<table id="Searchtable" cellspacing="0" summary="">';
echo '<caption>Job Priority: '.$value['Priority'][0].'</caption>';
echo '<tr>';
echo '<th scope="col" width="8%" abbr="Job Code" class="title">Job #</th>';
echo '<th scope="col" width="25%" abbr="Submitted By" class="header">Submitted By</th>';
echo '<th scope="col" width="25%" abbr="School" class="header">School - Location</th>';
echo '<th scope="col" width="20%" abbr="Problem" class="header">Type of Problem</th>';
echo '<th scope="col" width="22%" abbr="Equipment" class="header">Equipment</th>';
echo '</tr>';

echo '<tr>';
echo '<td class="start">'.$value['Job_Code'][0].'</td>';
echo '<td>'.$value['First'][0].' '.$value['Last'][0]. ' - '.$value['Phone'][0].'</td>';
echo '<td>'.$value['School'][0]. ' - '.$value['Location'][0].'</td>';
echo '<td>'.$value['Type'][0].'</td>';
echo '<td>'.$value['Machine_Type'][0].'</td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan="5" class="description"><span class="submitted">On '.$value['Date submitted'][0].' '.$value['First'][0].' Wrote: </span><br /> '.$value['Description'][0].'<br /><br /><span class="techassigned">Currently Assigned to:</span> '.$value['Assigned_to'][0].'</td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan="5" class="comments" >'.nl2br($value['Comments'][0]).'</td>';
echo '</tr>';
echo '<p class="minispace"></p>';
}
echo '</table>';
?>

It finds the right number of records to begin with i.e., it will state records found 20, displaying 1 through 15 records, however it just won't advance/backup any additional records. Thank you. Ken

#2 OFFLINE   webko  novice

webko
  • Members
  • 64 posts
  • LocationSydney, Australia
  • FM Client:11 Advance
  • Platform:Cross Platform
  • Skill Level:Expert
  • Membership:TechNet, FileMaker Business Alliance
  • Time Online: 13d 21h 12m 42s

Posted 22 February 2012 - 02:48 PM

Well, you've only ever said $skip = 0 - you'll need to pull the skip value from your LinkNext / LinkPrevious links


Back to FX.php


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

FMForum Advertisers