bluewaves Posted December 4, 2009 Share Posted December 4, 2009 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 https://forums.phpfreaks.com/topic/183924-running-2-php-scripts-on-one-page/ Share on other sites More sharing options...
haku Posted December 4, 2009 Share Posted December 4, 2009 First: Can't help you without code. Second: This is a PHP question. Moving it to that forum. Link to comment https://forums.phpfreaks.com/topic/183924-running-2-php-scripts-on-one-page/#findComment-970942 Share on other sites More sharing options...
JAY6390 Posted December 4, 2009 Share Posted December 4, 2009 Just use three includes and set the numbers before you include then $col_num_var = 3; include('script1.php'); $col_num_var = 2; include('script2.php'); $col_num_var = 3; include('script3.php'); Link to comment https://forums.phpfreaks.com/topic/183924-running-2-php-scripts-on-one-page/#findComment-970949 Share on other sites More sharing options...
bluewaves Posted December 4, 2009 Author Share Posted December 4, 2009 O.k. I will try that. Can you tell me if my strategy needs to be changed? I currently just run the three scripts right on the actual page. Is that a dumb idea? Thanks Link to comment https://forums.phpfreaks.com/topic/183924-running-2-php-scripts-on-one-page/#findComment-971240 Share on other sites More sharing options...
JAY6390 Posted December 4, 2009 Share Posted December 4, 2009 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 https://forums.phpfreaks.com/topic/183924-running-2-php-scripts-on-one-page/#findComment-971280 Share on other sites More sharing options...
bluewaves Posted December 4, 2009 Author Share Posted December 4, 2009 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 https://forums.phpfreaks.com/topic/183924-running-2-php-scripts-on-one-page/#findComment-971315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.