Jump to content

[SOLVED] Help With Using Include PHP File


limitphp

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/149273-solved-help-with-using-include-php-file/
Share on other sites

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

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.