Guest dana Posted March 12, 2009 Report Share Posted March 12, 2009 very new to php. Basically I have two divs [sidebar and content]. The sidebar contain a accordian style navigation made up of ul's and li's. My table contains 5 fields:id,name,generic,url and tier. I am able to get the data to display from the database. I want to be able to display the different data in the content div whenever the link is clicked in the navigation bar! I just can't get them to work together. In the content area of the page is the following code: <?php while($website_row = mysql_fetch_array($website_result)) { ?> <?php echo $website_row['generic']." of ".$website_row['name']; ?> <?php } ?> In the navigation bar is code similar to this: United States Canada Mexico I am not sure what code to put in the navigation area so that when someone click on the United State or Canada, etc. it will display the data in the content area without loading a whole new page. It seems simple enough but I don't know enough to figure it out. Hope someone can help. I would greatly appreciate it. thanx Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted March 12, 2009 Report Share Posted March 12, 2009 Well, in the olden days, you would be using a Frameset and a target of the content area frame, but these are not the olden days, so things have changed. PHP is a server-sdie scripting language and it requires the link to be processed back at the server, so that would be out of the question, apparently. That leaves javascript, or AJAX, which is javascript with http requests and junk, which does not require a full page request, however, it might not be the wisest thing to do here. Simply refresh the current page with a php request and pass the contents as a query string. To simplify the issue, have a look at using a Content Management System would be my suggestion. Quote Link to comment Share on other sites More sharing options...
cornetofreak Posted March 27, 2009 Report Share Posted March 27, 2009 heya, if i understand you correctly this is what id do, index.php contains 2 divs in menu div id have > </pre> <ul> United States Canada Mexico </ul> and within the leftbar i would do <?php $allowed = array("ca","us","mx"); $location = $_GET['location']; if( in_array( $location , $allowed ) ){ if(file_exists($location.".php")){ $file = $location.".php"; include "$file"; }else{ include "us.php"; } } ?> this way when you click a menu on your left bar it will be sent to the url and as the new page loads up php will read the value of location in the url and check it to make sure that it allowed to be included. hope this helps! Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.