spacepoet Posted November 16, 2011 Share Posted November 16, 2011 Hello: I wanted to see if someone can help me figure out how to include data from my included navigation file. Meaning: I have this file called myNav.php (the database table storing this is "myUpcomingEvents"): function spLeftMenu() { $spLeftMenu = " <div id=\"sideEvents\"> echo \" $mySideBarData; \"; </div> "; return $spLeftMenu; } I am trying to pull it into the Index.php page like this (the database table storing this is "myHome"): <?php include('include/myConn.php'); include('include/myNav.php'); $query=mysql_query("SELECT * FROM myHome,myUpcomingEvents") or die("Could not get data from db: ".mysql_error()); while($result=mysql_fetch_array($query)) { $myPageData=$result['myPageData']; $mySideBarPageData=$result['mySideBarPageData']; } ?> <!DOCTYPE HTML> <html> <head></head> <body> <div id="siteContainer"> <div id="leftColumn"> <?php echo spLeftMenu(); ?> </div> <div id="mainContent"> <?php echo $myPageData; ?> </div> </div> </body> </html> Can't get it to work. It just writes out: echo " ; "; Anyone know how I can get this to work? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/251226-help-including-a-navigation/ Share on other sites More sharing options...
Drummin Posted November 16, 2011 Share Posted November 16, 2011 I would quote the variables. Speaking of variables, see something missing? <?php echo spLeftMenu(); ?> Try <?php echo "$spLeftMenu()"; ?> Assuming $spLeftMenu() has been defined in your included files. Quote Link to comment https://forums.phpfreaks.com/topic/251226-help-including-a-navigation/#findComment-1288571 Share on other sites More sharing options...
spacepoet Posted November 16, 2011 Author Share Posted November 16, 2011 Hi: Thanks for the reply, but it did not work. Speaking of variables, see something missing? Not sure what you mean ... what did I miss? The: <?php echo spLeftMenu(); ?> Works fine as far as displaying the DIVs/layout/Design on the "Index.php" page: <div id=\"sideEvents\"> echo \" $mySideBarData; \"; </div> I just can't get the data from the database (mySideBarData) to display. Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/251226-help-including-a-navigation/#findComment-1288575 Share on other sites More sharing options...
Drummin Posted November 16, 2011 Share Posted November 16, 2011 Hey sorry about earlier post. Didn't see the function spLeftMenu at the top and assumed it should have been a variable. What you posted here is a little confusing as you are escaping your quotes on the <div id=\"sideEvents\"> and then in correctly for the echo line. <div id=\"sideEvents\"> echo \" $mySideBarData; \"; </div> It should be either echo "<div id=\"sideEvents\">$mySideBarData</div>"; OR <div id="sideEvents"> echo "$mySideBarData"; </div> Quote Link to comment https://forums.phpfreaks.com/topic/251226-help-including-a-navigation/#findComment-1288598 Share on other sites More sharing options...
spacepoet Posted November 16, 2011 Author Share Posted November 16, 2011 OK, thanks for the help and for clarifying! Much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/251226-help-including-a-navigation/#findComment-1288604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.