What is the syntax for printing large chunks of HTML inside a PHP if string, or can't it be done.

I want to print a different Paypal Button depending on a user's input from the radio buttons

I.E.

if ($size == "small")
{
print (<form action"www.paypal.com/webscr" method="post"><img src="about another ten lines of html tags">)
}

I have tried everything: echo with brackets only outside the HTML, print with ' single quotation marks outside the Html tags ' "Double Html tags outside the html and (" brackets and quotatiuons both sides oif the HTML.

Error message says that the first "<" is unexpected it was expecting ";" or ","

I know you can print HTML inside a php print line, so where am I going wrong.

    More like:

    if ($size == "small")
    {
        echo '<form action="http://www.paypal.com/webscr" method="post"><img src="about another ten lines of html tags" />';
    }

      I personally make it a defacto standard to use echo even though technically print and echo are interchangeable. Also you have to make sure of the quote scheme you use (single or double) when writing your code and to escape all necessary characters properly.

        And of course if you just want to output a chunk of HTML with no PHP variables in it, you can simply escape out of PHP mode:

        <?php
        if($size == 'small')
        {
        ?>
        <form action"www.paypal.com/webscr" method="post">
        <p><img src="about another ten lines of html tags">
        Etc., etc., and so forth.</p>
        </form>
        <?php
        }
        ?>
        

          Of course! That always work too 😉

            Laserlight, I had already tried your method, but I tired it again and it didn't work.

            Nogdog your way was perfect for what I wanted to do and it works perfect, thank you very much.

            I'm thinking:

            In the html form

            <input type="hidden" name="customer_number" value=" ">

            And in the PHP

            I wrote about three different chinks of code her and ended up admitting defeat. Truth is I haven't a clue, loads of ideas but none that will do it.

            I want to add one to $customer_number everytime the page is accessed

            and make $customer_number a hidden value in a form, which I know how to do.

              Laserlight, I had already tried your method, but I tired it again and it didn't work.

              What did you try? If you have a chunk of HTML code with little or no PHP code that needs to be embedded in it, then what NogDog suggested is usually better. However, both ways are functionally the same.

                LiamBaily
                to create the order number you could use mysql to find the order number but this is quite complex if you are just starting. another method i usw is to produce a random number between say 1000 and 9999, the chances of the same number is quite low. to do this use...

                <input type="hidden" name="item_name" value="Order #<?php echo rand(1000,9999); ?> " />

                Simple!

                  benracer wrote:

                  the chances of the same number is quite low.

                  Which is fine for a test environment, but when moving the script to a production environment this would never be acceptable. A better method would be to simply run an INSERT query to store the data and then use [man]mysql_insert_id/man to retrieve the unique ID# of the row stored.

                  As laserlight suggested, you should show us what you tried before so that we can help you figure out what went wrong. Note that you have to escape your string delimiters when outputting HTML, otherwise you'll get syntax errors. For examples, you should visit the manual page [man]language.types.string[/man].

                    Write a Reply...