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

Featured Replies

Hi there,

I want to add a web page that says "Your Search has Found no Courses." I have the following code for search_for_courses.php:

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

$course_name=$_REQUEST['course_name'];

$course_code=$_REQUEST['course_code'];

$starting_date=$_REQUEST['starting_date'];

$venue=$_REQUEST['venue'];

$venue_information=$_REQUEST['venue_information'];

$presenters=$_REQUEST['presenters'];

$stream=$_REQUEST['stream'];

$keyword=$_REQUEST['keyword'];

$new_course=$_REQUEST['newcourse'];

$type_of_search=$_REQUEST['type_of_search'];

if(isset($_REQUEST['skip'])){

$skipSize=$_REQUEST['skip'];

}else{

$skipSize='0';}

$groupSize='20';

if (isset($_REQUEST['page']) && is_numeric($_REQUEST['page'])) {

$skipSize = $groupSize * ($_REQUEST['page'] -1);

}

$Course_Search=new FX($serverIP,$webCompanionPort,'FMPro7');

$Course_Search->SetDBData('Course Information.fp7','Course Information',$groupSize);

$Course_Search->SetDBPassword('fmsadmin','fmsadmin');

if ($type_of_search == "OR") { $Course_Search -> AddDBParam('-lop', 'or'); }

$date = explode('/', $starting_date);

if(count($date)==3) $starting_date = $date[1] . '/' . $date[0] . '/' . $date[2];

$Course_Search->AddDBParam('Course_Name',$course_name, 'cn');

$Course_Search->AddDBParam('Course_Code',$course_code, 'eq');

$Course_Search->AddDBParam('Course_Date_First',$starting_date, 'eq');

$Course_Search->AddDBParam('Venue_Name',$venue, 'eq');

$Course_Search->AddDBParam('Stream_Name',$stream, 'eq');

$Course_Search->AddDBParam('Course_Description',$keyword, 'cn');

$Course_Search->AddDBParam('All_Presenters',$presenters, 'eq');

$Course_Search->AddSortParam('Sort_Order','descend');

$Course_Search->AddSortParam('Course_Date_First','ascend');

$Course_Search->FMSkipRecords($skipSize);

$Course_SearchResult=$Course_Search->FMFind();

$returnedCount=$Course_SearchResult['foundCount'];

echo $Course_SearchResult['errorCode'];

foreach($Course_SearchResult['data'] as $key=>$Course_SearchData);

$searchVariable=explode('.',$key);

$currentRecord=$searchVariable[0];

?>

***HTML goes here***

<?php

foreach($Course_SearchResult['data'] as $key=>$Course_SearchData){

$searchVariable=explode('.',$key);

$currentRecord=$searchVariable[0];

$course_URL = "find_this_course_single.php?recid=$currentRecord";

if ($Course_SearchData['Course_Capacity'][0] == 'Course Finished')

$course_URL = "course_details_no_reg.php?recid=$currentRecord";

if ($Course_SearchData['Course_Capacity'][0] == 'Course Has Started')

$course_URL = "course_details_no_reg.php?recid=$currentRecord";

if ($Course_SearchData['Course_Capacity'][0] == 'No longer accepting registrations')

$course_URL = "course_details_no_reg.php?recid=$currentRecord";

if ($Course_SearchData['Rescheduled'][0] == 'X')

$course_URL = "rescheduled.php?recid=$currentRecord";

if ($Course_SearchData['Course_Capacity'][0] == 'Full/Join Waiting List')

$course_URL = "waiting_list.php?recid=$currentRecord";

if ($Course_SearchData['Special_Course_1'][0] == 'RGF')

$course_URL = "course_details_DL_only.php?recid=$currentRecord";

if ($Course_SearchData['Special_Course_1'][0] == 'CP')

$course_URL = "course_details_DL_only.php?recid=$currentRecord";

?>

I need to add another if statement here that cuts in if the foundCount is zero but I cant work out how to code it. The second part of the statement would be something like

$course_URL = "no_courses_found.html";

Not sure if ?recid=$currentRecord"; needs to be added at the end of the above code since either no recid is found on a foundCount of zero or maybe the recid = 0 in such cases - Im not sure.

The php 'count' function (http://www.php.net/manual/en/function.count.php) will tell you how many elements are in an array. I'm not really up on the all the details of FX.php but it seems pretty clear your found record set is coming back in an array. It should be pretty easy to do your 'if' statement to check for zero array elements and take appropriate action.

Regards, Don

Counting items in a multipurpose array probably isn't the best idea.

There is a specific array key foundCount which is already being used above. If all you wanted to do was redirect the user if no records were found, something like this might work:

if( $returnedCount < 0 ) {

header( "Location: noRecords.php" );

exit();

}

Just ensure you put it in before you output any actual html to the browser.

But the whole redirect for error pages never really made sense to me, why aren't you just handling it in the same page?

Create an account or sign in to comment

Important Information

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

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.