Skip 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.

FX.php & linkNext / LinkPrevious?

Featured Replies

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

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) {

	?>

	&laquo;- Previous

	<?php

	} else {

	?>

	<a href="<?php echo $_SERVER['PHP_SELF'] ?>?skip=<?php echo($skipSize - $max) ?>"><strong>&laquo;- Previous</strong></a>

	<?php

	}

	?>

	</td>

	<td style="width:200px;text-align:left;">

	<?php

	if (strlen($result['linkNext']) < 1) {

	?>

	Next -&raquo;

	<?php

	} else {

	?>

	<a href="<?php echo $_SERVER['PHP_SELF'] ?>?skip=<?php echo($skipSize + $max) ?>"><strong>Next -&raquo;</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~

  • Author

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

  • Author

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

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

  • Author

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>&laquo; Previous</span> | ";

		} else {

		  echo "<a href="table.php?skip=" . ($skip-$groupSize) . "&recNum=" . $recNumP . $queryURL . "">&laquo; Previous</a> | ";

		}

		if (strlen($ReturnedData['linkNext']) < 1) {

		  echo "<span>Next &raquo;</span>";

		} else {

		  echo "<a href="table.php?skip=" . min(($skip+$groupSize), $ReturnedData['foundCount']) . "&recNum=" . $recNum . $queryURL . "">Next &raquo;</a>";

		}

	 ?>



  

It's a horrible, overly verbose, (almost) completely non-portable solution, but hey, it works!

Thanks everyone for your help.

Cheers,

Kevin

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.