3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 23   (RSS)

I have an issue passing the month, day and year to a URL request with the form below. It appears to pass correctly, however; it does not filter via the request!

<?php
$today = date("j");               // day of month
$month = date("M");               // Month such as Jan
$year  = date("Y");               // Year such as 2020
?

<form action="acknowledgements.php?" method="get">
<?php $optionValues = [1,2,3,4,5,6,7,8,9,10,11,12]; ?>
<?php $optionLabels = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; ?>
<?php $optionsHTML  = getSelectOptions(@$_REQUEST['acknowledge_date:mon'], $optionValues, $optionLabels); ?>
<select name='acknowledge_date:mon'  id='acknowledge_date:mon' class='form-control'><option value='<?php echo ($month); ?>'><?php echo ($month); ?></option><?php echo $optionsHTML; ?></select>
<?php $optionsHTML = getSelectOptions(@$_REQUEST['acknowledge_date:day'], range(1,31)); ?>
<select name='acknowledge_date:day'  id='acknowledge_date:day' class='form-control'><option value='<?php echo ($today); ?>'><?php echo ($today); ?></option><?php echo $optionsHTML; ?></select>
<?php $optionsHTML = getSelectOptions(@$_REQUEST['acknowledge_date:year'], range(2019, 2020)); ?>
<select name='acknowledge_date:year' id='acknowledge_date:year' class='form-control'><option value='<?php echo ($year); ?>'><?php echo ($year); ?></option><?php echo $optionsHTML; ?></select>
<input type="submit" id="acknowledge_date" class="btn btn-success btn-sm active type=" type="button" value="Print Acknowledgements">
</form>

I pass it via a URL to another page with the following header request:

// load records from 'collection_accounts'
  list($collection_accountsRecords, $collection_accountsMetaData) = getRecords(array(
    'tableName'   => 'collection_accounts',
    'allowSearch' => true,
  ));

Any help would be appreciated!

nmsinc

Hi nmsinc, 

Here's some feedback if you're still working on this one.

The date code looks good, you can test what's being received by PHP with: 

<?php showme($_REQUEST); ?>

And then see what SQL is getting generated (or not generated) by getRecords() with the debug option: 

  'debugSql' => true,

And then review the search docs: https://www.interactivetools.com/docs/cmsbuilder/viewer_search.php

And based on that I'd recommend the following changes: 

  • Change acknowledge_date:mon to acknowledge_date_month
  • Change acknowledge_date:day to acknowledge_date_day
  • Change acknowledge_date:year to acknowledge_date_year

Or if you want to quickly test it or not change your code you can just put this before getRecords(): 

<?php
  $_REQUEST['acknowledge_date_month'] = @$_REQUEST['acknowledge_date:mon'];
  $_REQUEST['acknowledge_date_day']   = @$_REQUEST['acknowledge_date:day'];
  $_REQUEST['acknowledge_date_year']  = @$_REQUEST['acknowledge_date:year'];
?>

Hope that helps! Let me know if it works for you.  

Dave Edis - Senior Developer
interactivetools.com