Theonlybrains Posted October 2, 2012 Share Posted October 2, 2012 Hi Guys,I am trying to add links to my menus for that the navigation becomes dynamic, when I include the links my menus disappear and I am left with bullet points and when I hoover the mouse around the menu arrears it shows that a link has been created even though there is no text visible. When I click it shows me that the link has taken me to a different area according to the menu. Please help me identify where I am going wrong for the text to disappear the code is as follows: <?php$subject_set = get_all_subjects(); while($subject= mysql_fetch_array($subject_set)){ echo "<li><a href=\"content1.php?subj=".urlencode($subject["id"])."\">{$subject["menu_name"]}</a></li>";$page_set = get_pages_for_subject($subject["id"]);echo "<ul class=\"pages\">";while($page = mysql_fetch_array($page_set)){ echo "<li><a href =\"content1.php?page=".urlencode($page["id"]). "\"{$page["menu_name"]}</li>";}echo "</ul>";}?> </ul> Many thanks Link to comment Share on other sites More sharing options...
niche Posted October 2, 2012 Share Posted October 2, 2012 Please post your function. Link to comment Share on other sites More sharing options...
Theonlybrains Posted October 2, 2012 Author Share Posted October 2, 2012 hi, this is the functions that I have included: <?php// this is a basic functions file function confirm_query($result_set){if(!$result_set) {die("Database query failed: ". mysql_error());}} function get_all_subjects(){global $connection;$query =("SELECT * FROM subjects ORDER BY position ASC");$subject_set = mysql_query($query, $connection);confirm_query($subject_set);return $subject_set;} function get_pages_for_subject($subject_id){global $connection;$query = "SELECT * FROM pages WHERE subject_id= {$subject_id} ORDER BY position ASC";$page_set = mysql_query($query,$connection);confirm_query($page_set);return $page_set;}?>Thanks Link to comment Share on other sites More sharing options...
niche Posted October 2, 2012 Share Posted October 2, 2012 (edited) Thanks. Please also post the html that your code generated. I can't spot the problem yet. Edited October 2, 2012 by niche Link to comment Share on other sites More sharing options...
Theonlybrains Posted October 2, 2012 Author Share Posted October 2, 2012 Thanks for looking,This is the code, the connection to the database works ok though, Everything worked fine until included the links.<?php require_once("includes/db_connection.php");?><?php require_once("includes/functions.php");?><?php include("includes/header.php");?><?php?><table id="structure"><tr><td id="navigation"><ul class="subjects"><?php$subject_set = get_all_subjects();while($subject= mysql_fetch_array($subject_set)){ echo "<li><a href=\"content1.php?subj=".urlencode($subject["id"])."\">{$subject["menu_name"]}</a></li>";$page_set = get_pages_for_subject($subject["id"]);echo "<ul class=\"pages\">";while($page = mysql_fetch_array($page_set)){ echo "<li><a href =\"content1.php?page=".urlencode($page["id"]). "\"{$page["menu_name"]}</li>";}echo "</ul>";}?><!-- </ul> --></td><td id= "page"><h2> Content Menu</h2><?php echo $selected_subj; ?><br /><?php echo $selected_subj; ?><br /></td></tr></table><?php require("includes/footer.php");?> Before adding the links,my code was:<?php$subject_set = get_all_subjects();while($subject= mysql_fetch_array($subject_set)){ echo "<li>{$subject["menu_name"]}</li>";$page_set = get_pages_for_subject($subject["id"]);echo "<ul class=\"pages\">";while($page = mysql_fetch_array($page_set)){ echo "<li>{$page["menu_name"]}</li>";}echo "</ul>";}?></ul>The code gave me the list of all the subjects, after adding the links, the list disappears and I am only left with bullets points. Where I hoover the mouse around where the list was, it shows that there is a link about bout and if you click it changes on the address bar, before the click: localhost/brain_corp/content1.phpand after the click : localhost/brain_corp/content1.php?subj=2thanks again, please be patient with me as I am still trying to learn my way around php.Thanks again Link to comment Share on other sites More sharing options...
niche Posted October 2, 2012 Share Posted October 2, 2012 (edited) Thanks, but we need the html that's produced from your page source. Also, if you're not already using developer tools, please start (ie firebug for firefox and in Chrome it's built-in, etc). Edited October 2, 2012 by niche Link to comment Share on other sites More sharing options...
justsomeguy Posted October 2, 2012 Share Posted October 2, 2012 Check the syntax of your <a> tag here: echo "<li><a href =\"content1.php?page=".urlencode($page["id"])."\"{$page["menu_name"]}</li>"; Link to comment Share on other sites More sharing options...
Theonlybrains Posted October 2, 2012 Author Share Posted October 2, 2012 <!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>Brain Corp</title> <link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css" /> </head> <body><div id="header"><h1>Brain Corp</h1> </div> <div id= "main"> <table id="structure"> <tr> <td id="navigation"> <ul class="subjects"> Link to comment Share on other sites More sharing options...
Theonlybrains Posted October 3, 2012 Author Share Posted October 3, 2012 I did check the syntax and that does not seem to be the problem. The closing tag got lost while I was posting on here! Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2012 Share Posted October 3, 2012 Well, I can only comment on the code that I'm seeing here. The closing tag isn't the only problem, the opening tag also doesn't close. If you're not seeing the text in the link then the tag is the problem, assuming those variables actually contain non-empty text. Link to comment Share on other sites More sharing options...
Theonlybrains Posted October 3, 2012 Author Share Posted October 3, 2012 Thank you guys I will review my html code, and the syntax. I real appreciate your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now