Jump to content

This topic is 6763 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi there,

I now have a working search form and search results page. What I need to do now is make the Course Code and Presenter Names in each row of the search results table into clickable links which activate an action that searches a database for information on the selected course or presenter and displays it in a new HTML page. Is this difficult to code?

Cheers,

Steven

Posted (edited)

ok, so you want me to elaborate ???

You need a recordID:

Below your 'foreach()' statement:

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

$currentRecord=$searchVariable[0];





Then for the record:





<? echo $Course_SearchData['Course_Code'][0];  ?>

This is roughly what the code will look like, you can change the particular code to fit your solution.

Good luck

Edited by Guest
Posted

<?

$pages=ceil($returnedCount/$groupSize);

if($pages>'1'){

$i='1';

$x='0';

?>

<? echo $i; ?>

<?

while($i<$pages){

$x=$i*$groupSize;

$i++;

echo ' | '

?>

<? echo $i; ?>

<?

}

}

?>

Course CodeCourse NameStream NameDurationCourse Starts OnVenue NamePresentersCourse Capacity

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

<? echo $Course_SearchData['Course_Code'][0]; ?><? echo $Course_SearchData['Course_Name'][0]; ?><? echo $Course_SearchData['Stream_Name'][0]; ?><? echo $Course_SearchData['Course_Length_Days'][0]; ?><? echo $Course_SearchData['Course_Date_First'][0]; ?><? echo $Course_SearchData['Venue_Name'][0]; ?><? echo $Course_SearchData['All_Presenters'][0]; ?><? echo $Course_SearchData['Capacity_Message'][0]; ?>

<? } ?>

Posted

Here is where the code goes:

blah blah blah...

$Course_SearchResult=$Course_Search->FMFind();

$returnedCount=$Course_SearchResult['foundCount'];

echo $Course_SearchResult['errorCode'];

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

//my inserted code to find the current recordID

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

$currentRecord=$searchVariable[0];

Next we need to make a clickable link in your list.

You need to have a detail page that it goes to that will look up more information:

In your table:

...

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

<? echo $Course_SearchData['Course_Code'][0]; ?>

Note that this link goes to another PHP page called detail.php.

On that page you need to do a look-up in the database on recid.

In detail.php you need:

$recid = $_REQUEST['recid'];

Play with this a bit and hopefully you will be able to get it...

Posted

Course_Code: <? echo $show found courseData['Course_Code'][0]; ?>

Course_Name: <? echo $show found courseData['Course_Name'][0]; ?>

Course_Length_Days: <? echo $show found courseData['Course_Length_Days'][0]; ?>

All_Course_Dates: <? echo $show found courseData['All_Course_Dates'][0]; ?>

Starting_Time: <? echo $show found courseData['Starting_Time'][0]; ?>

Finishing_Time: <? echo $show found courseData['Finishing_Time'][0]; ?>

Venue_Name: <? echo $show found courseData['Venue_Name'][0]; ?>

All_Presenters: <? echo $show found courseData['All_Presenters'][0]; ?>

Course_Description: <? echo $show found courseData['Course_Description'][0]; ?>

Course_Cost: <? echo $show found courseData['Course_Cost'][0]; ?>

Course_Cost_Members: <? echo $show found courseData['Course_Cost_Members'][0]; ?>

Course_Cost_Notes: <? echo $show found courseData['Course_Cost_Notes'][0]; ?>

Course_Cost_Notes: <? echo $show found courseData['Course_Cost_Notes'][0]; ?>

Assessment_Cost: <? echo $show found courseData['Assessment_Cost'][0]; ?>

Capacity_Message: <? echo $show found courseData['Capacity_Message'][0]; ?>

Posted

At the top of the detail page:

instead of

$Course_Code=$GET['Course_Code'];

Use:

$recid = $_REQUEST['recid'];

Then:

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

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

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

//to get the course - we use recid instead.

$show_found_course->AddDBParam('-recid', $recid);

//note that I don't like spaces in my variable names and have replaced spaces with '_'

This should get you on the right track...

Posted

Course_Code: <? echo $show_found_courseData['Course_Code'][0]; ?>

Course_Name: <? echo $show_found_courseData['Course_Name'][0]; ?>

Course_Length_Days: <? echo $show_found_courseData['Course_Length_Days'][0]; ?>

All_Course_Dates: <? echo $show_found_courseData['All_Course_Dates'][0]; ?>

Starting_Time: <? echo $show_found_courseData['Starting_Time'][0]; ?>

Finishing_Time: <? echo $show_found_courseData['Finishing_Time'][0]; ?>

Venue_Name: <? echo $show_found_courseData['Venue_Name'][0]; ?>

All_Presenters: <? echo $show_found_courseData['All_Presenters'][0]; ?>

Course_Description: <? echo $show_found_courseData['Course_Description'][0]; ?>

Course_Cost: <? echo $show_found_courseData['Course_Cost'][0]; ?>

Course_Cost_Members: <? echo $show_found_courseData['Course_Cost_Members'][0]; ?>

Course_Cost_Notes: <? echo $show_found_courseData['Course_Cost_Notes'][0]; ?>

Course_Cost_Notes: <? echo $show_found_courseData['Course_Cost_Notes'][0]; ?>

Assessment_Cost: <? echo $show_found_courseData['Assessment_Cost'][0]; ?>

Capacity_Message: <? echo $show_found_courseData['Capacity_Message'][0]; ?>

Posted

Steven,

The one error I see is on Line 12 (by my count) and that is the dreaded missing ';' (semicolon).

Also, in testing and trying to figure out what is going on with the code - remember to simplify and get one thing working.

You can try to comment out lines if you think something might be missing, or not working. Then watch what line the error says after commenting out lines... etc.

Another test piece of code is:

print_r($_REQUEST);

This will list all the items in ($_GET, $_POST, and $_COOKIE)

Note: The $_REQUEST function only works on PHP later than 4.1. If for some reason you are still on PHP 4.0 - upgrade your PHP.

Good Luck,

Mark

Posted

Thanks Mark,

I am checking with our IT manager re verion of PHP being used.

According to the latest error message The DBParam is where the code is getting stuck.

I notice that the reference to 'recid' is preceded by a '-' in the $show function code but not in the $request - is this right?

Thanks again,

Steven

Posted

The line with $show_found_course->SetDBParam('-recid', $recid) is missing the semi-colon.

'-recid' is the correct way to enter it.

Also, check all database names for case sensitivity. Once again, I am not a fan of names without spaces as some servers will gag if a database name, variable, etc has a space in it.

This should work with the semi-colon added.

If it doesn't and you are using an old version of PHP, then switch $_REQUEST with $_GET.

Keep me posted - hope you get it working.

Mark

Posted

Hi Mark,

I thought I had it by changing SetDBParam to AddDBParam but it just found the first record in the found set.

Error message is:

Fatal error: Call to undefined function: setdbparam() in /Library/WebServer/Documents/find_this_course.php on line 5

We are using PHP v4.2 so no problem with $_REQUEST

Does the DB need to have an actual ID field added? Or does PHP just read from the Filemaker background record ID code?

Is there another way to pass a variable?

Cheers,

Steven

Posted

I just noticed after sending last post that AddDBParam is correct (from your previous posts) but whenm i run the script its finding the last record in the found set (from the stage 1 search).

Cheers,

Steven

Posted

Sounds like you are having a fun morning:

Sorry if I confused things (I answered from home and totally missed the SetDBParam vs AddDBParam) - but the code should be:

$recid = $_REQUEST['recid'];

$groupSize='1';

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

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

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

$show_found_course->AddDBParam('-recid', $recid);

$show_found_courseResult=$show_found_course->FMFind();

echo $show_found_courseResult['errorCode'];

foreach($show_found_courseResult['data'] as $key=>$show_found_courseData);

If the link is correct from the previous page, this will load in one single record based on Filemaker's Record ID internal numbering.

The thing I haven't seen is when you echo the errorCode what number do you get? The page should show '0' with no errors, otherwise, there will be another number that may help track things down.

Posted

Hi Mark,

Don't apologise mate you've been an enormous help so far. Below is the code from the search_for_course.php script. It contains the code that passes the variable on to the find_this_course.php script. It also has code for doing the same thing with the presenters, venues and course names. Can you see any errors there?

Course Code

Course Name

Stream Name

Duration

Course Starts On

Venue Name

Presenters

Course Capacity

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

//should the "{" be there (just above) or is there a missing "}"? The next "}" is at the very end of the code. The code relating to find_this_course.php come next:

<? echo $Course_SearchData['Course_Code'][0]; ?>

<? echo $Course_SearchData['Course_Name'][0]; ?>

<? echo $Course_SearchData['Stream_Name'][0]; ?>

<? echo $Course_SearchData['Course_Length_Days'][0]; ?>

<? echo $Course_SearchData['Course_Date_First'][0]; ?>

<? echo $Course_SearchData['Venue_Name'][0]; ?>

<? echo $Course_SearchData['All_Presenters'][0]; ?>

<? echo $Course_SearchData['Capacity_Message'][0]; ?>

<? } ?>

Cheers,

Steven

Posted

I see where the trouble lies...

Your $currentRecord variable needs to be defined after the foreach()

So your code above:

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

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

$currentRecord=$searchVariable[0]; ?>

Here is the PHP lesson on foreach():)

The syntax is:

foreach(variable) ...

{

Do something that changes as the variable changes

}

The '{' and '}' define the begin and end of the loop and you can put anything you like in the loop.

Each new loop (course) needs a new unique recid that filemaker can lookup.

If you want to follow what is happening and see the recid's you can add another column (temporarily) that echos $currentRecord. They should all be unique.

Hope this works.

Mark

Posted

I know this comment is going to be off topic but I have to say it.

Steven,

Please look into using Cascading Style Sheets (CSS) for your layout design. I see lots of references to font size, family, color etc.

If at ANY time you want to update your site you will have to manually replace each and every occurrence of these on each and every page.

If you had a single css document you could update in one place and the entire site would pick up the changes.

You would need to use a couple of classes to replicate your design on this page. A class can be applied to any element on the page. This too would also make your code cleaner when viewing.

Some resources are;

http://www.w3.org/Style/CSS/

http://en.wikipedia.org/wiki/Cascading_Style_Sheets

http://www.htmlhelp.com/reference/css/

http://www.csszengarden.com/

Sorry for the O/T.

Posted

Thanks Andy. Im using Golive which is new to me and I tend to code HTML manually when I get sick of figuring out how to do things in the application. I have started learning the Golive CSS stuff and will switch everything over soon.

This topic is 6763 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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