Jump to content

[SOLVED] How do I use include in multiple links


adchico

Recommended Posts

I have the index.php

 

other pages:

about.php

index.php

contact.php

 

In this page I have a table where I want the other pages

to show when I click its link.

 

I know how to use

<?php include("about.php") ?>

 

but how will i use this to trigger different pages to show in a table cell if I click the about link or the contact link?

 

 

 

 

Link to comment
Share on other sites

Im sorry about that ... Im just a noob in php ... Im going to make this as simple as I can =)

 

 

I have a page index.php with tables in it

I have several links

 

Home     About     Contact Us

 

When a Link is selected, how can I make the Page to be opened, open up in one of the tables?

 

here is what im trying to do

 

 

if Home link is selected

<td><?php include("index.php"); ?></td>

if About link is selected

<td><?php include("about.php"); ?></td> <--- in the same table cell

if Contact Us link is selected

<td><?php include("contact.php"); ?></td> <--- in the same table cell

Link to comment
Share on other sites

First off, your not a noob. We all started off somewhere. All you need to make this work is a some sort of variable that you can pass through to the script.

So no matter what link your user clicks on he or she will always be sending a message to the php script. In this example I used a get var in the url query.

I have it so each link has a section variable. The code below works in both php 4 and php 5 environments. The only thing that would need to be change is the HTTP_GET_VAR.

PHP 5 doesn't use HTTP_GET_VARS anymore so it would need to be replaced with $_GET.

 

<table>
<tr>
	<td><a href="?section=home">Home</a></td>
	<td><a href="?section=about">About</a></td>
	<td><a href="?section=contact">Contact</a></td>
</tr>
<tr>
	<?php
	$section = $HTTP_GET_VARS["section"]; //$_GET if your using php5

	if($section == "home") {
		include("home.php");
	}

	if($section == "about") {
		include("about.php");
	}

	if($section == "contact") {
		include("contact");
	}
	?>
</tr>
</table>

Link to comment
Share on other sites

Im sorry here is the code

 

I followed the instruction on the link:

 

<td width="93"><div align="center" class="style40">

 

<a href="?section==home">Home</a></div></td>

   

<td width="96"><div align="center" class="style49 style44 style45">

 

<a href="?section==about">About Us</a></div></td>

 

 

and the code of include in the table cell:

 

<?php

$section = $_GET["section"];

//$_GET if your using php5

 

if($section == "home")

{

include("index.php");

}

 

if($section == "about")

{

include("about.php");

}

?>

 

</td>

 

   

Link to comment
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.