webref.eu Posted September 2, 2006 Share Posted September 2, 2006 Hi AllI 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 Quote Link to comment Share on other sites More sharing options...
tomfmason Posted September 2, 2006 Share Posted September 2, 2006 Maybe it would be better for you to write a function and then call the function in your script as needed. Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 2, 2006 Share Posted September 2, 2006 nope your have to use a function() then call that function on the page.warning.include more then a few times will give you problams always use a function and call that function from a .php page.so you make the function on a page.php then you incude once that page and use the function as meny time as you need it. Quote Link to comment Share on other sites More sharing options...
webref.eu Posted September 2, 2006 Author Share Posted September 2, 2006 Thanks guys. Do I write the function in it's own .php file? If so, what is the syntax to include the function in the page? What is the syntax to call a function and send it a specific value of a variable at the same time? Many thanks Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 2, 2006 Share Posted September 2, 2006 function();// This is a function.function me();// This is a function named me.function var($var);//this is a function named var and got a varable to be used inside the function or outside the function.return function name()/ / this is used to return a function within it self.when you want a function to be seen from another page always include() that .php page then call the function() as shown belowgood luck.function.php[code]<?phpfunction date_today($date_today){$date=date("d-m-y");echo $date;}?>[/code]call the function[code]<?php//include the functioninclude("function.php");// call the function throw the include.function date_today($date_today);?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.