Problem with clean URL

I have a menu that displays data fine, the url for the first menu looks like this: http://…com/prehistoric-egypt, and as expected loads the data from the database.

I have ten menu ‘headers’ each with it’s own links to pages. The one mentioned has a ‘header’ and for sub-menu - the header is not a link, just text. The problem occurs when I select a different ‘header’ sub-menu. For example, I have Archaic Period as a sub-menu, so I was expecting the url to be http://…com/archaic-period, but instead I get http://…com/prehistoric-egypt?=archaic-period and does not load the data. The first part after.com/ changes depending on what page I was on first so this could be http://…com/homet?=archaic-period.

I include the html / php code for the menu / sub menu:

<div class="dropdown">
			
				 <button class="dropdownButton">Pre 3150 BC</button>
				 
				 <div class="dropdownContent">
				 
				 <?php
				 	
				 	$q = "SELECT * FROM pages LIMIT 4 OFFSET 5";
					$r = mysqli_query($dbh, $q);
					
					while( $nav = mysqli_fetch_assoc($r) ){
						
					echo '<a href="' . $nav['slug'] . '">' . $nav['pagelinks'] . '</a>';

					}
				 ?>
				 
				</div>
				 
			</div><!-- dropdown end -->
		
		</span>
		
		<img src="images/line.png" alt="A Line">
		
		<span class="item">
		
			<div class="dropdown">
			
				 <button class="dropdownButton">3150 – 2686 BC</button>
				 
				 <div class="dropdownContent">
				 
				  <?php
				 	
				 	$q = "SELECT * FROM pages LIMIT 3 OFFSET 9";
					$r = mysqli_query($dbh, $q);
					
					while( $nav = mysqli_fetch_assoc($r) ){
						
					echo '<a href="?=' . $nav['slug'] . '">' . $nav['pagelinks'] . '</a>';

					}
				 ?>
				 
				</div>
				 
			</div><!-- dropdown end -->

Pre 3150 BC is the first ‘header’ with calls to load in date to display the links etc.

How do I resolve this issue so I can show the pages I want?

Any help will be appreciated…

You have this, so that makes sense.

echo '<a href="?=' . $nav['slug'] . '">'
1 Like

Thank you for the reply. The issue is with the second menu and its sub menu

Menu 1 Menu 2
Home sub a
About sub b
etct etc

Lets say I select Home so the url will correctly be http://…com/home. However, should I then select sub a, the url becomes http://…com/home?sub a, and as mentioned does not load sub a’s data. It must be the php code I am using to SELECT the data, but I don’t see a way around having http://…com/sub a appear in the url along with the data. I assume I’m missing something. Is it the fact that I have more than one set of php code using SELECT?

Any help will be appreciated.

you would need to be able to determine the entire route. So if the main page is:

page1 and it has
slug1
slug2
slug3

page2
slug10
slug11
slug12

You need to know what that page is to add the link properly

1 Like

Will do, thanks for the help.

So, why the limit and offset? S menu is an odd place for pagination.

Sponsor our Newsletter | Privacy Policy | Terms of Service