Results 1 to 4 of 4

Thread: Newb PHP Question

  1. #1
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Newb PHP Question

    So I am relatively new to PHP and I am trying to simply get this small bit of code to work.

    <?php if ($row_rsCWGetProduct["product_TypeInput"] == 1) {
    <form id="GeneralName" name="GeneralName" method="post" action="">
    <label for="Name">Name:</label>
    <input name="Name" type="text" id="Name" size="20" maxlength="100" />
    </form>
    <label for="textfield">Name</label>
    <input type="text" name="textfield" id="textfield" />
    }
    ?>

    The gist is that if the vale of the first variable is 1, then the form box will display (I know that I still need to code to make it functional, but I need it to display first).

    When I comment out the form bits, the page displays fine, but when they are included and the value is 1, I get the error:

    Parse error: syntax error, unexpected '<'

    On the 4th line down.

    Can anyone help me with this simple basic question? All help is greatly appreciated.

    I figured it out, moderator, you can remove this thread. Thanks
    Last edited by drconehead2000; 07-25-2008 at 02:58 PM. Reason: Help no longer needed

  2. #2
    Join Date
    Jul 2008
    Posts
    102
    Thanks
    36
    Thanked 6 Times in 6 Posts

    Default

    Your mixing HMTL with PHP?? Thats like me ¡Hablando de repente español, usted acostumbrado puede comprender un dicho de palabra Im! (#translation#-suddenly speaking spanish, you wont be able to understand a word Im saying!)

    Also please place code between code tags, the moderators dont like lose code

    Code:
    <?php if ($row_rsCWGetProduct["product_TypeInput"] == 1) {
    echo "<form id=\"GeneralName\" name=\"GeneralName\" method=\"post" action=\"\">\n";
    echo "<label for=\"Name\">Name:</label>\n";
    echo "<input name=\"Name\" type=\"text\" id=\"Name\" size=\"20\" maxlength=\"100\" />\n";
    echo "</form>\n";
    echo "<label for=\"textfield\">Name</label>\n";
    echo "<input type=\"text\" name=\"textfield\" id=\"textfield\" />\n";
    }
    ?>
    backslash \ to escape " character for the string out. I would recommend doing a PHP tutorial, just google it and that should get you started. This is basic "Hello World" stuff so you will find that all this is covered in the first part of any tutorial you find.

    Kind regards
    Dal
    Programmers are tools used to convert Caffeine to code

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Better:
    Code:
    <?php if ($row_rsCWGetProduct["product_TypeInput"] == 1): ?>
      <form id="GeneralName" name="GeneralName" method="post" action="">
        <label for="Name">Name: </label>
        <input name="Name" type="text" id="Name" size="20">
        <label for="textfield">Name</label>
        <input type="text" name="textfield" id="textfield">
      </form>
    <?php endif; ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jul 2008
    Posts
    102
    Thanks
    36
    Thanked 6 Times in 6 Posts

    Default

    Better isnt a word I would use there actually Twey more like "Different"
    Programmers are tools used to convert Caffeine to code

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •