MrTIMarshall Posted April 2, 2013 Share Posted April 2, 2013 Hello, Firstly, I would like to know how to setup a page, of which you can do something alike the following; mydoman.com/InteractiveMapDataFetch.php?=COUNTRY=United-Kingdom&Region1=England - Fetches England Data mydoman.com/InteractiveMapDataFetch.php?=COUNTRY=United-Kingdom&Region1=England&Region2=North-West - Fetches England, North-West Data Each page will have code on to be fetched by the bigger document, just plain code with no styling as the style sheet is attached to the bigger document and whatnot. This is my idea on how to have my massive page, not be so massive in code at a singular time to enhance loading speeds and whatnot. Secondly, I would like to know how to have a content switcher via a link click where the current data will be removed and the new data will be loaded. Could someone please help me make a very basic version of this to get to grips with and then implement it into my website? Thank you for any time spend in following up my question and for any help and/or advice given. Best Regards, Tim Quote Link to comment https://forums.phpfreaks.com/topic/276441-setting-up-then-fetching-data-from-another-internal-page/ Share on other sites More sharing options...
ignace Posted April 3, 2013 Share Posted April 3, 2013 Having a page that has several widgets on it that in it's own queries an URL is gonna be painfully slow. What is it exactly that you want to build? Secondly, I would like to know how to have a content switcher via a link click where the current data will be removed and the new data will be loaded.You mean like with Ajax? Quote Link to comment https://forums.phpfreaks.com/topic/276441-setting-up-then-fetching-data-from-another-internal-page/#findComment-1422694 Share on other sites More sharing options...
QuickOldCar Posted April 4, 2013 Share Posted April 4, 2013 For your first question, you would make a script and use a GET request, it does not require a form, but can use one as well. http://php.net/manual/en/reserved.variables.get.php http://www.tizag.com/phpT/postget.php For the second question, ajax as ignace stated if want it dynamic without leaving the original page. https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started Quote Link to comment https://forums.phpfreaks.com/topic/276441-setting-up-then-fetching-data-from-another-internal-page/#findComment-1422808 Share on other sites More sharing options...
trq Posted April 4, 2013 Share Posted April 4, 2013 I don't think you really want to to making separate http requests to get the data you are after. What I actually think your trying to do could easily be solved with functions. For example: function fetchMapData($country, $regions = array()) { // For real, you would generate $data from the database most likely // As an example though, I'm just hard coding it into the function $data = array( 'england' => array( 'south-west' => 'this is south west data', 'north-west' => 'this is north west data' ), 'ireland' => array( 'south-west' => 'this is south west data', 'north-west' => 'this is north west data' ) ); $out = array(); if (count($regions)) { foreach ($regions as $region) { $out = $out[] = $data[$country][$region]; } } else { foreach ($data[$country] as $region => $value) { $out[] = $value; } } return $out; } var_dump(fetchMapData('england')); // return all regions within england var_dump(fetchMapData('england', array('north-west'))); // return just north west region var_dump(fetchMapData('england', array('south-west', 'north-west'))); // return south west & north west region This hides all your logic within one place, the fetchMapData() function and makes it very easy to retrieve in multiple different pages without duplicating the code everywhere. Does this help? Quote Link to comment https://forums.phpfreaks.com/topic/276441-setting-up-then-fetching-data-from-another-internal-page/#findComment-1422831 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.