Cenron Posted May 30, 2007 Share Posted May 30, 2007 Anyone know of a good way of passing a parameter to one of my php files while I am including it so for example I want to do this include("display.php?p=3"); That doesn't end up working for me and I know why,because it uses the system file directory and doesn't run it through the PHP engine yet, in any cause I though of doing it this way but I want to see if there was a better way. My idea was do it this way index.php $parameter = $_GET["p"]; include(display.php); display.php $query = mysql_query("SELECT * FROM `display` WHERE `display_id` = '$parameter' "); echo "$query"; I know there is more to the code above but this was how I was thinking about doing it. any suggestions on doing this a better way? Link to comment https://forums.phpfreaks.com/topic/53660-include-with-paramters/ Share on other sites More sharing options...
trq Posted May 30, 2007 Share Posted May 30, 2007 If you have url wrappers enabled you can achieve this by including via the full url. eg; include "http://yourdomain.com/display.php?p=3"; Link to comment https://forums.phpfreaks.com/topic/53660-include-with-paramters/#findComment-265252 Share on other sites More sharing options...
Cenron Posted May 30, 2007 Author Share Posted May 30, 2007 I thought of that but it seems like on a big scale that would increase the amount of traffic generated from the site. Link to comment https://forums.phpfreaks.com/topic/53660-include-with-paramters/#findComment-265256 Share on other sites More sharing options...
trq Posted May 30, 2007 Share Posted May 30, 2007 Well, that the only other option. It works a little differently to a normal include anyway in that you don't inherit the functions and vars included, just the output. Link to comment https://forums.phpfreaks.com/topic/53660-include-with-paramters/#findComment-265257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.