Help required with search not working.

4 posts by 2 authors in: Forums > CMS Builder
Last Post: June 23, 2017   (RSS)

By willydoit - June 22, 2017

Hi all,

I have a table called advertisers and a field called services_provided.

I have a listing page which displays all the records within the table. I want to place a drop down list containing all the services provided and to be able to select a particular service from the list and then display only the advertisers providing those services.

My page displays all advertisers by default and also displays my drop down list but the search is not filtering the results.  I am sure it will be something simple but for the life of me I cannot see the issue.

My top of page code looks like this;

  // load viewer library
  $libraryPath = 'cmsb/lib/viewer_functions.php';
  $dirsToCheck = array('#############/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records from 'advertisers'
  list($advertisersRecordsFeatured, $advertisersMetaDataFeatured) = getRecords(array(
    'tableName'   => 'advertisers',
    'orderBy'     => 'RAND()',
    'where'        => 'listing = "Featured Listing"', 

  ));
    list($advertisersRecordsStandard, $advertisersMetaDataStandard) = getRecords(array(
    'tableName'   => 'advertisers',
    'orderBy'     => 'RAND()',
    'where'        => 'listing = "Standard Listing"', 

  ));
    list($advertisersRecordsComplimentary,  $advertisersMetaDataComplimentary) = getRecords(array(
    'tableName'   => 'advertisers',
    'orderBy'     => 'RAND()',
    'where'        => 'listing = "Complimentary Listing"', 

  ));

?>

and my drop down list and search form looks like this

 <form method="post" action="http://www.lpl-testsite.co.uk/bridlington-business-directory.php?">
        
        
       <select name="services_provided">
        <?php foreach (getListOptions('advertisers', 'services_provided') as $value => $label): ?> 

<option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['services_provided']);?>>

<?php echo $label; ?></option> 

<?php endforeach ?> 

      
         
         </select>
<br/>
        
        
        <div align="center">
          <input type="submit" name="search" value="  Search Listings  "/>
        </div>
        
        
        
</form>

If anyone can spot the most likely daft mistake I have made I would be grateful for you pointing it out.

Thanks in advance for any help provided.

By willydoit - June 22, 2017

Hi Dave,

thanks for the help and suggestions, will implement those today, I havent done anything since making the post and it is also working for me now, no idea why. Sorry to have wasted your time.

By Dave - June 23, 2017

No worries, let us know if you need anything else or the problems come back.  Cheers!

Dave Edis - Senior Developer
interactivetools.com