Hi guys hoping someone can help me out please.....

Got the code where a side menu appears with sub-pages link which are related to the main body article. To do this I used the the command - where project_id = $show. That works fine but the problem lies in when I select a sub-page the side menu's contents disappears.

I know the reason for this is because the $show has now changed to the sub_page id and not the main. Is there anyway to get around this as I want the side_menu to always show extra options with are related to the original choice of article. Thanks in advance....

$result = mysql_query("SELECT * FROM  sub_pages where main_id = $show");
	if (!$result)	
	die("query failed: " . mysql_error());	
	if (mysql_num_rows($result) > 0) 
	while($row = mysql_fetch_array($result))
	echo $row['title'];	
	echo GetMoreLink ($site_url, 'sub_projects.details.php?show='.$row['id']);
8 Years
Discussion Span
Last Post by diafol

rename the variable to something else.

Rather than call the Variable $show call it $project_id and then have one for sub menu called $sub_menu. It's much easier to call the variable something meaningfull.


Thanks for the tip.

Unfortunately that doesn't solve the problem. What I need is a way of holding on or storing to the $project_id variable so when I click onto the sub project page the statement

SELECT * FROM  sub_pages where main_id = $project_id

will still work.

Once I click back to the page where all the projects are listed together that stored $project_id could then be cleared.



It all depends how your sidebar is populated. Your querystrings need to clearly differentiate between a link to a main article and one for a sidebar element.

You could get away without using any sessions/cookies if you do this.
A main link could be: ...projects/details.php?main_id=3.

The page then identifies the project. If a $_GET is available (e.g. projects/details.php?main_id=3&sub_id=15), then show the sub article, otherwise, show the main article.
The $_GET is then used to call the sidebar elements from the db. This could be produced thus:

$main_id = mysql_real_escape_string($_GET['main_id']);
$rs = mysql_query("SELECT * FROM subs WHERE main_id = '$main_id'");
$output = "<ul>\n\t<li><a href='projects/details.php?main_id={$main_id}' title='go to main article'>Main article</a></li>";
while($line = mysql_fetch_array($rs)){
   $output .="\n\t<li><a href='projects/details.php?main_id={$main_id}&sub_id={$line['sub_id']}' title='go to {$line['title']}'>{$line['title']}</a></li>"
$output .="\n</ul>";
//you may want to unescape/stripslash your text items first though
//then just echo the $output variable in the relevant place.

Sorry if this ain't what you're looking for.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.