#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    OK,here's the scoop. I've got 3 variables in a form: products[], ib, wl. products[] contains whichever values where checked from about 20 checkboxes, and the other two (ib, wl) are either "yes" or "no". The reason for this is that there is a limit of 4 products to order, except for ib/wl which don't count as part of the 4. Now, want the values to be sent by e-mail: "Products: ql, ba, wl". I did [b]$prod = implode (",",$products);[b], and then I would like to append ", wl" to $prod IF the value is "yes" and also ", ib" if the value is "yes". How would I do that? Thanks!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    $yourstring .= ( $wl == "yes" ) ? ", wl" : "";
    $yourstring .= ( $ib == "yes" ) ? ", ib" : "";

    ?

    ------------------
    - weeder
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    Hmmm, it doesn't send me an e-mail anymore now. This is what I have:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    //$products comes from another page as an array
    $prod = implode (",", $products);
    $prod .= ($wl == "yes") ? ",wl" : "";
    $prod .= ($ib == "yes") ? ",ib" : "";

    mail("terium@techie.com","$subject","$title $first $lastn$addressn$address2n$city, $state $zipnnProducts: $prod","From: $emailnX-mailer: PHP/" . phpversion())
    [/code]

    Before I added the "$prod .= ..." lines, it e-mailed me.
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    I think it might be the :'s added to $prod. Try using a different delimiter.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    While I waited for a reply, I added some code to keep the right option selected in the lists and the right checkboxes to be checked. For some reason or another I get the e-mail now. =)

    I have one more problem, though. I have an Address1 and Address2 field... if they leave Address2 blank, I don't want it to go down a line. I have this now:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>mail("terium@techie.com","$subject","$title $first $lastn$addressn$address2n$city, $state $zipnnProducts: $prod","From: $emailnX-mailer: PHP/" . phpversion())[/code]

    Now, I COULD have it append n to every field I need and then mail only the fields (with the n in them instead of outside)...but isn't there a better way?

    Just realized: the code $prod .= ($wl == "Yes") ? ",wl" : ""; doesn't work for some reason. I do get the e-mail, though..

    [This message has been edited by terium (edited July 19, 2000).]
  10. #6
  11. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    Just realized: the code $prod .= ($wl == "Yes") ? ",wl" : ""; doesn't work for some reason.


    actually that condition should work fine..
    I think you must have given your check box value "yes"(you are checking for value "Yes")...that may be the reason it is not checking that value properly..



    <<
    if they leave Address2 blank, I don't want it to go down a line.
    >>



    try like this.

    <?
    $message=$title."".$first.$last."n";
    $message.=$address."n";

    if (isset($address2)){
    $message.=$address2."n";
    }

    $message.=$city.", ".$state." ".$zip."nn";
    $message.="Products: ".$prod;

    mail("terium@techie.com","$subject",$message,"From: $emailnX-mailer: PHP/" . phpversion())
    ?>


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited July 20, 2000).]
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    OK, I fixed everything and it all works fine. The only thing I have to do now is to make the confirmation page "pretty" =)

Similar Threads

  1. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 07:50 PM
  2. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 11:56 AM
  3. mgetty+sendfax on RH9
    By ayrin in forum Linux Help
    Replies: 0
    Last Post: January 31st, 2004, 03:11 AM
  4. Problems with my first DLL
    By lloydie-t in forum Delphi Programming
    Replies: 2
    Last Post: December 7th, 2003, 02:48 PM
  5. Advice on reversing order of characters within a string?
    By FriscoKid in forum C Programming
    Replies: 5
    Last Post: November 13th, 2003, 09:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo