Affiliate Marketing
Forum Search


Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 02-09-06
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,314
Thanks: 8
Thanked 29 Times in 26 Posts
accelerator is an unknown quantity at this point
  PHP pass variable to include within include statement?

Hi All

I have the following include file:

<?php include("inc-select-merchants-by-keyphrase.php"); ?>

Currently, I set a $KeyphraseAds variable for it at the top of my php page, to get merchants for the relevant keyphrase, and it displays a table of merchant results.

However, this only allows one table of results on a page, and I would sometimes like to display multiple tables of results, i.e. use the include file more than once, but set a different $KeyphraseAds each time.

Is there a way of setting an include specific variable, maybe within the include statement itself, to allow me to use the same include multiple times on a page but each time displaying different keyphrase results?

I guess what I'm asking is, is there a way to send a variable to a specific instance of a php include?

Many thanks

Accelerator
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-09-06
Registered User
 
Join Date: Nov 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
epetoke is an unknown quantity at this point
Sounds like you need to create an array with all the different keywords you want then a For or While Loop which will loop through all the keywords you want and include the appropriate files you want.

Do a google search for "php array" and "php for loop"
__________________
I don't like hidden campaigns unless i can see them

Golf Gear: www.golfguy.co.uk | Mobile Content: www.topdogtones.com | Children's Toys: www.toyhound.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-09-06
eskimo's Avatar
Registered User
 
Join Date: Aug 2003
Posts: 659
Thanks: 0
Thanked 0 Times in 0 Posts
eskimo is an unknown quantity at this point
Quote:
I guess what I'm asking is, is there a way to send a variable to a specific instance of a php include?
Can't you just reassign $keyphrase a new value just prior to each include?
eg
PHP Code:
$keyphrase 'ipod';
include(
"inc-select-merchants-by-keyphrase.php");
.....
some more code.......;
$keyphrase 'headphones';
include(
"inc-select-merchants-by-keyphrase.php"); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-09-06
OLBG's Avatar
aka Antony
 
Join Date: Mar 2005
Location: Bristol
Posts: 528
Thanks: 0
Thanked 0 Times in 0 Posts
OLBG is an unknown quantity at this point
sounds like you need to make the include into a function

Put the include statement at the start of your page

In the include, wrap it in a function

function merchant_table($KeyphraseAds)
{
//all the content of your original include here
}

then in the main body just call the function when you want the results

merchant_table("ipod");

//other stuff maybe

merchant_table("shoes");

etc
__________________
Antony
Free Tipster Competition
Affiliate Program on POR - up to £2/lead
Grand National Guide
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 03-09-06
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,314
Thanks: 8
Thanked 29 Times in 26 Posts
accelerator is an unknown quantity at this point
Agreed, a php function would be the way to do this.

Thanks everyone.

Rgds
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Including a PHP include within a PHP include ?? madstock Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 17-12-03 10:00 PM
Php Include scifind Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 5 14-08-03 05:01 AM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7