David's correct. The reason it wasn't working for you is that you didn't put
braces around the code you wanted executed in the if statement. Also, to
output large chunks of html in a simple manner with variables included, look
into "here docs". They look like this:


echo<<<EOF
This is html with a $variable in it.
EOF;

jack

-----Original Message-----
From: David Robley [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 13, 2001 8:21 PM
To: Brad Melendy; [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Can If Else statements be split into code
blocks??


On Wed, 14 Nov 2001 11:43, Brad Melendy wrote:
> Ok, I figured out that just using echo seems to be the best way to do
> this under PHP.  In ASP, you can end your code block and start in with
> HTML, but I couldn't get that to work with PHP.  However, I was able to
> just use the echo statement to get the conditional HTML I wanted to
> show up when the proper condition was met in the If Else statement.
>
> ....Brad
>
> "Brad Melendy" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> > Hello,
> > I'm trying to execute some HTML in an IF ELSE statement.  I'm trying
> > something like:
> >
> > <?php
> >     if (strstr($DomResults,$Match))
> >     print "Congratulations!  $domain.$suffix is available!";
> > ?>
> >     <form method="POST" action="step2.asp" name="form2">
> >       <p><input type="submit" value="Register" name="B1"></p>
> >     </form>
> >
> > <?php
> >    else
> >     print "Sorry, $domain.$suffix is already taken.";
> > ?>
> >
> > Basically, it works great without the form I'm trying to insert, but
> > with the form after the IF statement, it fails.  Is what I want to do
> > against
>
> the
>
> > rules?  I'm converting an ASP script I have to PHP and I have it all
>
> working
>
> > under ASP.  That means it should be eaiser with PHP right?  ;-)
> > Thanks in advance.
> >
> > ...Brad

You can drop in and out of php parsing, even in a control structure. So
something like

<?php
if($this == 'that') {
?>
<H2>That</H2>
<?php
} else{
?>
<H2>The Other</H2>
<?php
}
?>

will work just fine.
--
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA

   Stop talking! I'm out of aspirin!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to