I have an "if" thing which is part of a processing script.

I want the script to generate a page using the HTML specified IF the if returns true.

So.. it'll be like:

<IF>
<HTML TO BE SHOWN>
<ELSE>
PRINT "WHATVER"

etc

I don't want it to include to a seperate page, but I want it to "excecute" or run the HTML if the if comes back true.

Please tell me how this could be done

ALex.

    This probably belongs in the newbies forum... but anyway, yes, that's one of the most basic things you can do with PHP.

    
    if ($something == $somethingelse) { 
    echo("<html><head><title>blah blah</title>"); 
    // or alternatively you can just include a file with your html
    include("myhtml.html");
    }
    else {
    echo("Whatever");
    }
    
    

      you can even mix them like this

      <?php
      if($something == $somethingelse) { 
      ?>
      <html><head><title>blah blah</title>
      <?php
      }
      else {
      ?>
      <different>
      </tags>
      <?php
      }
      ?>
      

        Does it matter if my HTML has " in it? Also, does it matter if the allignment is different?

        I.E. Instead of <tag1><tag2><tag3>

        it's

        <tag1>
        <tag2>
        <tag3>
        </tag1>
        </tag2>
        </tag3>
        ?

          coditoergosum, I am not stupid. I didn't want to have the HTML in an echo because it is a large peice of code.

          I do not appreciate being called a "newbie". I know enough HTML and PHP to make basic scripts. I just had never used a split if before.

          Good day to you!

            Umm... why does it say a PHP newbie under your name? Anyway, it is a very simple thing to do, and therefore belongs in the newbie forum. That's all I'm saying. Didn't say you were stupid... newbies aren't necessarily stupid, just not experienced yet.

            Also, I too don't like to echo large amounts of HTML, that's why I offered the alternate include statement.

              I don't want it to include to a seperate page

                <?
                $htmlscript = "<html><head><title>hellew</title></head></html>";
                
                if ($something == "something")
                {
                print ($htmlscript);
                }
                else
                {
                print ("i like chicken");
                }
                

                spacing isnt really isn a big issue with PHP so:
                <?php

                echo("hello");

                ?>

                is effectivley the same as:
                <? echo("hello"); ?>

                but make sure that when you do put hrml into a variable or really anywere in php, make sure you put a "\" before every inverted comma Ex

                $variable = "<a href=\"http://www.somewere.com\">";

                  Write a Reply...