Hey guys, I am creatiing a website where I need a sidebar with different links, each link will open a different version of the product page, only the content part will be different. I want to know how I can change the content part of the product part depending on the link clicked. IN the product page. Just now in the sidebar there are a few links, when one is clicked a subset of links should appear underneath, they are currently hidden, and whne they appear the content part will changeas well. So the links could be men,Women, Children, etc etc and each link when clicked will populate the content part of the product page. here is the sidebar just now:

<ul id="sb_home" class="sb">
		<li><a href="products.php">Men</a></li>
		<?php if($range == 'men') {echo "<ul>
				<li><a href='index.html'>Men link 1</a></li>
				<li><a href='index.html'>Men link 2</a></li>
				<li><a href='index.html'>Men link 3</a></li>
				<li><a href='index.html'>Men link 4</a></li>
			</ul>";}?>
		<li><a href="products.php">Women</a></li>
		<?php if($range == 'women') {echo "<ul>
				<li><a href='index.html'>Women link 1</a></li>
				<li><a href='index.html'>Women link 2</a></li>
				<li><a href='index.html'>Women link 3</a></li>
				<li><a href='index.html'>Women link 4</a></li>
			</ul>";} ?>
		<li><a href="products.php">Unisex</a></li>
		<li><a href="products.php">Youth</a></li>
		<li><a href="products.php">Teamwear</a></li>
		<li><a href="products.php">Accessories</a></li>
	</ul>

Here is what I have at the top of my product page:

<?php
   
	
	if( isset($_GET['range'])){
	$range = $_GET['range'];
	}
	
	
?>

I still have to write the code getting the content part to fill from a database query, I want to get this working first though.

Basically I want to populate the the content part with random items from my database table where the range is equal to men, that is what I am aiming for.

I appreciate any help with this as I am stuck.


Many thanks!

Member Avatar
<?php
  $range = (isset($_GET['range'])) ? $_GET['range'] : 'men'; //men = default
?>

       <ul id="sb_home" class="sb">
		<li><a href="products.php?range=men">Men</a></li>
		<?php if($range == 'men') {echo "<ul>
				<li><a href='index.html'>Men link 1</a></li>
				<li><a href='index.html'>Men link 2</a></li>
				<li><a href='index.html'>Men link 3</a></li>
				<li><a href='index.html'>Men link 4</a></li>
			</ul>";}?>
		<li><a href="products.php?range=women">Women</a></li>
		<?php if($range == 'women') {echo "<ul>
				<li><a href='index.html'>Women link 1</a></li>
				<li><a href='index.html'>Women link 2</a></li>
				<li><a href='index.html'>Women link 3</a></li>
				<li><a href='index.html'>Women link 4</a></li>
			</ul>";} ?>
		<li><a href="products.php?range=unisex">Unisex</a></li>
		<li><a href="products.php?range=youth">Youth</a></li>
		<li><a href="products.php?range=teamwear">Teamwear</a></li>
		<li><a href="products.php?range=accessories">Accessories</a></li>
	</ul>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.