Jump to content

Recommended Posts

Okay, no idea if this is going to work or not. I have a set up a footer php file with some hrefs to some generic pages (like "contact us", "about us", "faq").

 

Each link in the footer looks like this: <a href="genericpage.php?genpage=contactus">Contact Us</a>

 

Then I have several small php files that only have the content for each genpage query string. These are very simple files. Just some very basic HTML like this:

 

Please call 555-1212 to contact us<br /><br />

Our email address is <a href="mailto:[email protected]">[email protected]</a>

 

The above 2 lines are in a file called contactus.php. That's all that's in there.

 

genericpage.php is the following:

 

<?php

 

if (!isset($_GET['genpage']) || $_GET['genpage'] == '') {

header ('location: index.php');

exit;

} else {

 

if ($genpage == 'faq') {

$pageheader = "Frequently Asked Questions";

$pagecontent = 'genpage-faq.php';

} else if ($genpage == 'aboutus') {

$pageheader = "About Us";

$pagecontent = 'genpage-aboutus.php';

} else if ($genpage == 'contactus') {

$pageheader = "Contact Us";

$pagecontent = 'genpage-contactus.php';

} else if ($genpage == 'privacypol') {

$pageheader = "Privacy Policy";

$pagecontent = 'genpage-privacypol.php';

} else if ($genpage == 'copyrightnotice') {

$pageheader = "Copyright Notice";

$pagecontent = 'genpage-copyrightnotice.php';

} else if ($genpage == 'companydetail') {

$pageheader = "About Us";

$pagecontent = 'genpage-aboutus.php';

}

}

 

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?php echo $pageheader; ?></title>

</head>

 

<body>

<div id="wrapper">

    <?php include('header.php'); ?>

    <table style="background-image:url(images/header-bottom.gif); background-repeat:no-repeat; background-position:center; height:53px; width:1000px;" >

        <tr>

            <td valign="bottom" align="center">

                <p style="font-size:18px; font-weight:bold; margin:0; padding:0 70px 5px 0"><?php echo $pageheader; ?></p>

                </td>

            </tr>

        </table>   

   

    <table width="1000px" style="height:320px;">

            <tr style="background-image:url(images/green-edges.gif); background-repeat:repeat-y; ">

            <td style="padding:10px 0 0 40px">

              <?php include($pagecontent); ?>

                </td>

            </tr>                 

        </table>

<?php

            include('footer.php');

        ?>

    </div>

</body>

</html>

 

So as you can see from the above, depending on the link the user clicks in the footer, $pageheader and $pagecontent are being set when the page loads.

 

All this works just fine. No problems.

 

However, I have one link in the footer that needs to go to a specific section of the about us page. The about us page has a <a name="companydetail"> anchor in it. So what I want to have happen is when the user clicks the <a href="genericpage.php?genpage=companydetail">Company Detail</a> link in the footer, I want genericpage.php to load with include for aboutus.php but jump directly to the companydetail anchor on that page.

 

Not sure if this is possible and I'm going nuts trying to figure it out.

 

All this could lead to storing the content sections in a database as opposed to separate php pages (the part that goes here: <?php include($pagecontent); ?>). Not sure if that matters or not.

 

Hope someone can help.

 

Thanks. :)

 

Link to comment
https://forums.phpfreaks.com/topic/207076-using-include-with-anchors/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.