Rheal Posted March 24, 2005 Posted March 24, 2005 I have a few problems with my PHP Code. First and most important, I'm having issues with the link next and link previous links. If all records are shown the next and previous buttons work fine. If I do a search for certain criteria (example: manufacturer's name), then click the next link it returns no results (the url isn't correct) If I do a search and then sort (using some links in the table headers), then click the next link all is good. (the url is good) My second issue deals with the text that says which records are being shown (showing 8-14 of 20 records) The skip value doesn't seem to be functioning properly. Any help would be greatly appreciated. Rheal This is my current (half working) example http://www.advance-pro.com/infocentre/clearance.php My code include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/FX.php"); include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/server_data.php"); $Item_Query = new FX($serverIP, $webCompanionPort); $Group_Size = 7; // # of records shown per page $Item_Query->SetDBData("clearance_items.fp5", "general", $Group_Size); // fileMaker file, layout, and #of records shown per page $fmField = $_POST["fmfield"]; // field in form (for search by) $fmValue = $_POST["fmvalue"]; // value in form (for search by) $Item_Query->AddDBParam($fmField, $fmValue); // Search paramater (uses two previous fields in search) $arrayName = 'HTTP_' . $_SERVER["REQUEST_METHOD"] . '_VARS'; if (isset($_REQUEST ['skip']) && $_REQUEST['skip'] > 0) { $Item_Query->FMSkipRecords($_REQUEST['skip']); } if (isset(${$arrayName}['currentSort']) && ${$arrayName}['currentSort'] != '') { $Item_Query->AddSortParam($_GET['currentSort'], $_GET['sortOrder']); }else{ $Item_Query->AddSortParam('date_added','descend',1); } if (isset(${$arrayName}['currentQuery']) && ${$arrayName}['currentQuery'] == 'Find Items') { foreach (${$arrayName} as $key => $value) { if ($key == 'fmfield'){ $currentSearch .= "&" . urlencode($value); }else if ($key == 'fmvalue'){ $currentSearch .= "=" . urlencode($value); } else if ($key != 'currentSort' && $key != 'currentQuery') { $Item_Query->AddDBParam($key, $value); } } foreach (${$arrayName} as $key => $value) { if ($key == 'currentSort'){ $currentSearch = ""; } else if ($key == 'fmfield' || $key == 'fmvalue'){ $currentSearch; } else{ $Item_Query->AddSortParam( $_GET['currentSort']); $currentSearch .= '&' . $key ."=" . urlencode($value); } } $Item_Data = $Item_Query->FMFind(); } else { $currentSearch = ''; $Item_Data = $Item_Query->FMFindAll(); } ?>
gdurniak Posted March 25, 2005 Posted March 25, 2005 Instead of FX.php, try fm-and-php http://www.fm-and-php.info/ It's MUCH easier to use, and has great previous / next navigation functions Also, don't bother with FXForge for FX.php. It stinks
FMWebschool Posted March 28, 2005 Posted March 28, 2005 I'm sure that helped answer his question..? I also don't think that it is wise to make slanderous statements involving OUR software. FXForge is used by numerous companies and scholastic institutions. Now, onward to acutally helping : Here is the code. <?php include_once('FX/FX.php'); include_once('FX/FMErrors.php'); include_once('FX/server_data.php'); if(isset($_POST['skip'])){ $skipSize=$_POST['skip'];}else{$skipSize='0';} if(isset($_POST['type'])){ $type=$_POST['type'];}else{$type='';} $groupSize='5'; if($type=='next'){ $skipSize=$skipSize + $groupSize; } if($type=='prev'){ $skipSize=$skipSize - $groupSize; } $display=new FX($serverIP,$webCompanionPort,'FMPro7'); $display->SetDBData('Company.fp7','cgi',$groupSize); $display->SetDBPassword('password','Web'); $display->FMSkipRecords($skipSize); $displayResult=$display->FMFindall(); foreach($displayResult['data'] as $key=>$displayData); ?> <html> <head> </head> <body> <? if($skipSize <='0'){ }else{ ?> <form method='POST' action='testing.php'> <input type='hidden' name='type' value='prev'> <input type='hidden' name='skip' value='<? echo $skipSize; ?>'> <input type='submit' name='submit' value='Previous'> </form> <? } ?> <? if($skipSize+$groupSize >=$displayResult['foundCount']){ }else{ ?> <form method='POST' action='testing.php'> <input type='hidden' name='type' value='next'> <input type='hidden' name='skip' value='<? echo $skipSize; ?>'> <input type='submit' name='submit' value='Next'> </form> <? } ?> <table> <? foreach($displayResult['data'] as $key=>$displayData){ ?> <tr><td><? echo $displayData['name_first'][0]; ?></td><td><? echo $displayData['name_last'][0]; ?></td></tr> <? } ?> </table> <br></body> </html> Oh, and this was generated by FXForge took all of 2 seconds. www.fxforge.net
mlindal Posted April 21, 2005 Posted April 21, 2005 re: Slanderous statements Easy stephen - best to breath deeply and count to 10 :-) In response and support of FXforge: FXforge has taught me so much about coding PHP, and in particular the 'Next / prev' gymnastics. I also like the bonus of being able to code multiple pages like 1 | 2 | 3 | 4 | All this and more can be done in FXforge. And yes there are some short falls, but then I know there are new versions coming out soon, which will be even better.
Recommended Posts
This topic is 7225 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