Jump to content

Running 2 PHP scripts on one page


bluewaves

Recommended Posts

I'm running actually three different php scripts on one page. Everything works as far as display products,

but what happens is that you can designate the number of columns that the products display on each

individual script. So theoretically I should be able to show products in one table and select say 2 columns

wide and then use another script for another table and indicate a different column number.

 

The poor result is that the first declaration of the number of columns is what is shown in all three areas

where the script runs. It seems to inherit the call from the first script to the next script.  Is there any way

to stop this from happening?

 

I thought that if I enclosed the script within a table that would stop it, but it doesn't.

 

Any help would be appreciated.

 

Thanks,

 

Link to comment
Share on other sites

ideally you should have all logic done before you display anything.you should take a look at the MVC architecture. separating logic from your content is how it should be done.

 

with regards to your current predicament you may want to change each of your scripts into functions you can call with a column number as a parameter.

Link to comment
Share on other sites

Hi,

 

I am barely functional with php. I know just enough to get by. 

 

Are you saying that I set a variable in each script? If so, I need an example because of my lack of knowledge.

 

In the script I am using over and over,  This is what determines the columns:  define ("NUMCOLS", 3);

 

If there is just one script running on the page, all I do is change the number and that will change the column numbers, but not when several are running on the page.

 

Here are the names of the scripts I just separated out:

 

../php/hummingbird-checks1.php

../php/hummingbird-col.php

../php/hummingbird-calendars.php

 

Two of them are in the same area so I can call on them like this:

 

 

<?php

 

include('../php/hummingbird-calendars.php');

include('../php/hummingbird-col.php');

 

?>

 

Now if I follow your first layout would the new call look like this?

This would have 2 columns:

 

<?php

$col_num_var = 2;

include('../php/hummingbird-checks1.php');

?>

 

Then lower in the page, these would have 4 columns:

 

<?php

$col_num_var = 4;

include('../php/hummingbird-calendars.php');

$col_num_var = 4;

include('../php/hummingbird-col.php');

?>

 

Is that the right logic? Even though my original call on columns looks like this: 

 

define ("NUMCOLS", 3);

 

Thank you for your help.

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

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.