Adastra Posted August 1, 2006 Share Posted August 1, 2006 I have a document structured like this: [code=php:0]<?if ($_GET['p'] == "name1") {my contents } elseif ($_GET['p'] == "name2") {my contents } elseif ($_GET['p'] == "name3") {my contents }?>[/code]and so on. But now I need a string which gives me the contents of two of those strings, which somewhat includes the content of two of the strings in a new one together. [code=php:0]elseif ($_GET['p'] == "name_all") {content of name2 and name3}[/code]How can I do that? include() doesn't work, and I've tried various other stuff with echo, $_GET and print, but nothing works! I'm sure you can easily do this with some function I don't know about. Thanks in advance :) Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 Can you be more specific I dont understand what you mean to say Quote Link to comment Share on other sites More sharing options...
Adastra Posted August 1, 2006 Author Share Posted August 1, 2006 I want something like this: [code=php:0]elseif ($_GET['p'] == "name_all") {content of ($_GET['p'] == "name2") and ($_GET['p'] == "name3")}[/code]I don't know how to explain it better. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 1, 2006 Share Posted August 1, 2006 Nope, still not clear. Do you mean you want to test to see if $_GET["p"] contains "name2" and "name3"? Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 This would work perfectlyI get wat you mean[code]elseif ($_GET['p'] == "name_all"){include("$_SERVER[SCRIPT_FILENAME]?p=name2");include("$_SERVER[SCRIPT_FILENAME]?p=name3");}[/code]See its simple if you use get to get the content you can include the same script with different get parameters.:)hope dat helps Quote Link to comment Share on other sites More sharing options...
Adastra Posted August 1, 2006 Author Share Posted August 1, 2006 Hmmpf, it's not working, I get this error (multiple times): Warning: main(): Failed opening '/var/www/index.php?p=page3' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/unisys-outsourcing/index.php on line 5 Quote Link to comment Share on other sites More sharing options...
Ifa Posted August 1, 2006 Share Posted August 1, 2006 How about [code=php:0]include(__FILE__."?p=name2");[/code] Quote Link to comment Share on other sites More sharing options...
Adastra Posted August 1, 2006 Author Share Posted August 1, 2006 Nope, same error there :/ Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 then dun use vars like $_SERVER[SCRIPT_FILENAME] use the name like in this case index.php?p=name2 [/3] 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.