Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post

    Couple problems..

    Having problems with this if statement..

    I'm checking 2 form fields & their default value is "0" & I only want people to change them if they want to input another number... I don't want them taking away the "0" & leaving it blank.

    Thing is... this works if one is blank, but if I leave both blank I don't get any errors.

    PHP Code:
    if ($fmtext or $fmcheckbox == '') {

    echo 
    "Please leave all options you don't need set to zero & do not modify them.";

    exit();


    Also, how can you insert the value of a variable into a bunch of text without spaces in the text?

    Like this...

    $sn = 23;

    PHP Code:
    echo "iam$sntoday"// Doesn't work
    echo "iam"$sn"today"// Doesn't work
    echo "iam($sn)today"// Returns the brackets also but gets the value correct 
    Any tips?

    Thanks!

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post
    hey...

    1.
    PHP Code:
    if ($fmtext == "" || $fmcheckbox == ""
     { 
        echo 
    "Please leave all options you don't need set to zero & do not modify them."
     }

    // or if you really need to, you could use a set of elseifs

     
    if ($fmtext == ""
     { 
        echo 
    "Please leave all options you don't need set to zero & do not modify them."
     } 
     elseif (
    $fmcheckbox == "")
     {
        echo 
    "Please leave all options you don't need set to zero & do not modify them."
     } 
    || is used as OR and u need to check both cases

    2.
    PHP Code:
    $sn 23;
     echo 
    "I am " $sn " Today"
    You can use the fullstop (.) to join/glue strings and variables together

    Last edited by Serex; 05-14-2004 at 05:40 PM.

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Thanks! Got the first working but not the second.

    PHP Code:
    echo "<input type=\"text\" name=\"'fmtextquestion' . $sn . '-$textnum2'\" size=\"4\">\n"
    Outputs..

    PHP Code:
    <input type="text" name="'fmtextquestion' . 105 . '-1'" size="4"

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Before you post, read our: Rules & Posting Guidelines

    Specifically section 2 of the posting guidelines. Your subject line is not acceptable.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Sorry, I thought of that but it was kinda hard to explain them both in the title.

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Quote Originally Posted by cyphix
    Sorry, I thought of that but it was kinda hard to explain them both in the title.
    If it is not possible to be specific then a general subject is better like PHP and Form Fields or Problems with an "if" statement.

    Also if the two questions are unrelated then they should be put in two seperate topics.

    We do this to make it easier for others to find answers to their questions when they use the search feature and not have to weed through a lot of titles that are not obvious or have the discussion buried inside of a thread.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Yes... thats's cool.

    If I have a few things to cover I thought it was usually best to keep them in one thread as most other forums frown upon creating multiple threads when you could have put it all in one.

    Btw, I solved my problem..

    PHP Code:
    $texthm "fmtexthm" $sn "-$textnum2";

    echo 
    "<input type=\"text\" name=\"$texthm\" size=\"4\">\n"


  •  

    Posting Permissions

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