PHP includes
9 posts by 2 authors in: Forums > CMS Builder
Last Post: May 5, 2010 (RSS)
By NigelGordijk - May 5, 2010
I'm trying to use the following include inctruction, but get an error message:
contact-directory-individual.php?department=CAO Office
I want to use the same include file - contact-directory-individual.php - in different places on a page, so that only records that match specific departments appear; e.g. CAO Office, Clerk's Department...
The only other alternative that I can think of would be to set up separate cms sections for each department; one for CAO Office, one for Clerk's Department, etc.
Regards,
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] PHP includes
By Jason - May 5, 2010
To get the variable "department" to your include file, you can try this:
<?php
$_REQUEST['department']="CAO Office";
include("contact-directory-individual.php");
?>
Hope this helps. Let me know if you run into any problems.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] PHP includes
By NigelGordijk - May 5, 2010 - edited: May 5, 2010
Sorry, that doesn't seem to be working. The include displays all of the records, regardless of which department is requested. I've only input two records for testing: one for the department CAO office, and one for Castle Kilbride.
You can see an example here: http://www.wilmot.ca/contact-directory.php.
If you click on the blue headings "CAO Office" and "Castle Kilbride", you'll see both of the records on display.
For the Castle Kilbride section, I amended your code to:
<?php
$_REQUEST['department']="Castle Kilbride";
include("contact-directory-individual.php");
?>
Regards,
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] PHP includes
By Jason - May 5, 2010
So you want to set it up so that it will only display contact details for the department specified in $_REQUEST['department']? Is that right?
If you could attach contact-directory.php and contact-directory-individual.php I can take a look at it for you.
Thanks.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] PHP includes
By NigelGordijk - May 5, 2010
The CAO Department should only show Grant Whittington's details. Tracy and Sherri should only show up under Castle Kilbride.
The include is called contact-directory-individual.php. It appears on the page called contact-directory.php.
http://www.wilmot.ca/contact-directory.php
Thanks!
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] PHP includes
By Jason - May 5, 2010 - edited: May 5, 2010
Since you were selecting your records in "contact-directory.php", the passing of the variable to "contact-directory-individual.php" didn't change the records being returned.
Try replacing the code in "contact-directory-individual.php" with this:
<?php
list($contactsRecords,$contactMetaData)=getRecords(array(
'tableName' => 'individual_contacts',
'allowSearch' => true,
));
?>
<?php foreach ($contactsRecords as $record): ?>
<TABLE WIDTH="289" BORDER="0" CELLPADDING="0" CELLSPACING="0" ID="Individual">
<TR>
<TD CLASS="tdHorizontalRulePaleBelow">
<P><STRONG><?php echo $record['name'] ?></STRONG><BR>
<?php echo $record['title'] ?> - ext. <?php echo $record['extension'] ?><BR>
<A HREF="mailto:<?php echo $record['content'] ?>"><?php echo $record['content'] ?></A></P></TD>
</TR>
</TABLE>
<?php endforeach; ?>
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] PHP includes
By NigelGordijk - May 5, 2010
Notice: Undefined variable: contactsRecords in /var/www/vhosts/wilmot.ca/httpdocs/contact-directory-individual.php on line 7 Warning: Invalid argument supplied for foreach() in /var/www/vhosts/wilmot.ca/httpdocs/contact-directory-individual.php on line 7
http://www.wilmot.ca/contact-directory.php
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] PHP includes
By Jason - May 5, 2010
Thanks.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] PHP includes
By NigelGordijk - May 5, 2010
Many thanks for your help.
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net