General Community > Scripting Help

php problem: using both an echo() and an include() in an if-statement

(1/2) > >>

Seph|roth:
i want to do something like this:

<?php if (isset($box01)) echo ("<tr><td class=\"box\">") include ($box01) echo ("</td></tr>"); ?>

i know this is illegal, but maybe someone knows a way to accomplish this?

thanks!

Chris Cromer:

--- Code: ---<?php
if (isset($box01)) {
  echo ("<tr><td class=\"box\">");
  include ($box01);
  echo ("</td></tr>");
}
?>
--- End code ---
Is that what your wanting?

Seph|roth:
perfect! didn't know you could do it like that, still learning the basics ;)

thanks!

Seph|roth:
hmm I now encountered a very strange error. I'm using the method that Chris Cromer posted above, and this is the code to derermine what boxes are used:


--- Code: ---<?php switch ($_GET[&#39;main&#39;])
{

CASE "home":
$title = "Home";
$path = "Home";
$incMain = "/var/www/html/games/ff/site/home.php";
$box01 = "/var/www/html/games/ff/site/box_reldates.php";
break;

CASE "affiliates": ... etcetera ... ?>
--- End code ---

now, in Opera and IE/MyIE2 this works fine, but in Moz/Fibi the HTML (in "box_reldates.php" for this example) is simply not returned! :S How is this possible, it's a server-side thing, right? PHP sends the html to the browser... ?

Any ideas?

Aquilo:
could you be using POST in Moz/Fibi and GET with Opera and IE/MyIE2? that would be the only thing I can think that would make you case fail!

Navigation

[0] Message Index

[#] Next page

Go to full version