Jump to content

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?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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