kfutter Posted September 27, 2004 Posted September 27, 2004 Hi, I'm very new to FX and even PHP itself, so I'm struggling a little bit with it, but am making some headway. Anyway, I can't seem to figure out how to make linkPrevious and linkNext work. If I do this: $ReturnedData['linkNext'] as part of a link, it just reloads the page with the same (original) dataset, with 'skip=50&' appended to the URL. I've examined the FXExample file, but most of it just bewilders me. Can anyone give me some (gentle) advice? Cheers, Kevin Futter
Addam Posted September 29, 2004 Posted September 29, 2004 Here is some syntax you can modify and then use: Your request should look something like this: $max = 15; $skipSize = $_GET['skip']; $request=new FX("127.0.0.1"); $request->SetDBData("mydatabase.fp5","mylayout",$max); $request->AddDBParam("field","value","eq"); $request->FMSkipRecords($skipSize); $result=$request->FMFind(); Your previous and next could look like this: <table> <tr> <td style="width:200px;text-align:right;"> <?php if (strlen($result['linkPrevious']) < 1) { ?> «- Previous <?php } else { ?> <a href="<?php echo $_SERVER['PHP_SELF'] ?>?skip=<?php echo($skipSize - $max) ?>"><strong>«- Previous</strong></a> <?php } ?> </td> <td style="width:200px;text-align:left;"> <?php if (strlen($result['linkNext']) < 1) { ?> Next -» <?php } else { ?> <a href="<?php echo $_SERVER['PHP_SELF'] ?>?skip=<?php echo($skipSize + $max) ?>"><strong>Next -»</strong></a> <?php } ?> </td> </tr> </table> IF you modify the request code to fit your situation, the second code should work as is. I hope this helps! ~Addam~
kfutter Posted September 29, 2004 Author Posted September 29, 2004 Thanks Addam. Since posting the original question I've joined the FX mailing list and received some great help there from Chris Hansen himself (FX author), which closely echoes (pardon the pun) your suggestions here, although somewhat simplified. Basically, I neglected to put the $skipSize = $_GET['skip']; line in, so linkNext contained no value. I'm still having trouble getting it to work on a PC (works on Linux and OS X), so I'll try your method and see if it helps there. Cheers, Kevin
kfutter Posted September 29, 2004 Author Posted September 29, 2004 I'm replying to Addam here - I've tried your solution on a PC Addam, but haven't got it to work so far. It seems that the values contained in the original query string are not stored and passed to the script. All it inherits is the skip value. Anything I might be doing wrong? Cheers, Kevin
Garry Claridge Posted September 29, 2004 Posted September 29, 2004 This "$_SERVER['PHP_SELF']" may be the problem. Will this work: <a href="<?php $result['linkPrevious'] ?>">Previous</a> <a href="<?php $result['linkPrevious'] ?>">Next</a> Good Luck. Garry
kfutter Posted September 29, 2004 Author Posted September 29, 2004 Hi Gary, When I use the $result['linkPrevious'] and $result['linkNext'] expressions (which are supposed to hold the relevant parts of the previous query plus the default increment amount- '-max=' in CDML), I get something like this as the new URL: "/php/php.exe/?skip=50". When I use a version of Addam's suggestion, it finds the right PHP file, but doesn't inherit the previous query data. This is on a Win2k PC, Apache 2.047 and PHP 4.3.9 installed as a CGI, and I think this combination could be part of the problem, as the $result['linkPrevious'] and $result['linkNext'] expressions actually work fine on Mac OS X and our hosting service's Linux box. As I develop on Mac OS X at work to deploy on the provider's Linux box, I'm no longer under any pressure - I'm 'practising' on my PC at home, and curious/confounded as to the different behaviour. Anyway, for the curious, this is the solution that I got to work on the above described PC: <?php $recNumP = ($skip-$groupSize) + 1; //used for decrementing a table row count $queryURL = ("&ARTIST=" . $_GET['ARTIST'] . "&ALBUM=" . $_GET['ALBUM'] . "&DATE=" . $_GET['DATE'] . "&FORMAT=" . $_GET['FORMAT'] . "&SOURCE=" . $_GET['SOURCE']); if (strlen($ReturnedData['linkPrevious']) < 1) { echo "<span>« Previous</span> | "; } else { echo "<a href="table.php?skip=" . ($skip-$groupSize) . "&recNum=" . $recNumP . $queryURL . "">« Previous</a> | "; } if (strlen($ReturnedData['linkNext']) < 1) { echo "<span>Next »</span>"; } else { echo "<a href="table.php?skip=" . min(($skip+$groupSize), $ReturnedData['foundCount']) . "&recNum=" . $recNum . $queryURL . "">Next »</a>"; } ?> It's a horrible, overly verbose, (almost) completely non-portable solution, but hey, it works! Thanks everyone for your help. Cheers, Kevin
Recommended Posts
This topic is 7430 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now