limitphp Posted March 13, 2009 Share Posted March 13, 2009 I have alot of pages that will display songs. I use different styles of displaying the songs. Users can choose to use either style. There will be a checkbox that will allow them to change the style via ajax. In order to organize my code a little bit better, I would like to put each style of displaying the songs in their own include files. So, I'll have an include file called: inc_table_view.php and one called inc_vote_view.php In the pages that will use these include files, there will be a variable called $viewID that will control which one to use. In the php code on the pages that will use these includ files, could I do something like: if ($viewID==1) { include("inc_table_view.php"); } elseif ($viewID==2) { include("inc_vote_view.php"); } Does that seem like a logical way to handle this? Thanks for any advice... Quote Link to comment https://forums.phpfreaks.com/topic/149273-solved-help-with-using-include-php-file/ Share on other sites More sharing options...
ricmetal Posted March 13, 2009 Share Posted March 13, 2009 yes but that will only work if you refresh the page after the user submits their choice of style. or, if you use ajax to include the includes and dynamiclly change the style of the page without refreshing, which is more workfull but also possible Quote Link to comment https://forums.phpfreaks.com/topic/149273-solved-help-with-using-include-php-file/#findComment-783885 Share on other sites More sharing options...
Adam Posted March 13, 2009 Share Posted March 13, 2009 Not if called via ajax! Adam Quote Link to comment https://forums.phpfreaks.com/topic/149273-solved-help-with-using-include-php-file/#findComment-783889 Share on other sites More sharing options...
limitphp Posted March 13, 2009 Author Share Posted March 13, 2009 yes but that will only work if you refresh the page after the user submits their choice of style. or, if you use ajax to include the includes and dynamiclly change the style of the page without refreshing, which is more workfull but also possible When the main page (the one that has the include file in it) loads, it will grab a default value for viewID. When they uncheck or check the checkbox, it will refresh the main page via ajax. Will that work? Quote Link to comment https://forums.phpfreaks.com/topic/149273-solved-help-with-using-include-php-file/#findComment-783897 Share on other sites More sharing options...
Adam Posted March 13, 2009 Share Posted March 13, 2009 Yeah there's absolutely no reason why not. I think the trickiest bit would be creating a smooth interchange whilst loading the images.. Adam Quote Link to comment https://forums.phpfreaks.com/topic/149273-solved-help-with-using-include-php-file/#findComment-783900 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.