robcrozier Posted November 7, 2006 Share Posted November 7, 2006 ok, im trying to send an automated email to both me and webuser upon successful order completion. However the $message part has to contain if statements and later on for loops. Heres an example of what iv'e got so far.[code]$message = "Order Number : ".$_SESSION['order_no']." Order Date : ".date("F jS, Y")." Development time guaranteed : ". if ($_SESSION['e_commerce_check'] == 'yes') { echo ($_SESSION['turnaround_time+e-com']); } else { echo ($_SESSION['turnaround_time']); } ." Days Name : ".$_SESSION['name']." Address : ".$_SESSION['address1']."[/code]then i'll obviously include the variable $message in the sendmail statement :[code]mail($to, $subject, $message);[/code]though when ran - it does not allow the first 'if' statement, i did expect this like as it is being used within a variable initialisation. However does anyone have any siggestions as to how i can get round it.Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/26496-complex-sendmail-query/ Share on other sites More sharing options...
GeoffOs Posted November 7, 2006 Share Posted November 7, 2006 Why not calculate the $_SESSION bit before into a different variable:[code]if ($_SESSION['e_commerce_check'] == 'yes') { $check = ($_SESSION['turnaround_time+e-com']); } else { $check = ($_SESSION['turnaround_time']);}$message = " Order Number : ".$_SESSION['order_no']." Order Date : ".date("F jS, Y")." Development time guaranteed : ".$check." Days Name : ".$_SESSION['name']." Address : ".$_SESSION['address1'].";[/code]Or have I not understood the question? Quote Link to comment https://forums.phpfreaks.com/topic/26496-complex-sendmail-query/#findComment-121223 Share on other sites More sharing options...
robcrozier Posted November 8, 2006 Author Share Posted November 8, 2006 Yeah that's sorted that 1 out mate cheers, why did i not think of that. lol.Anyway i wonder if you could help me with a for loop in the same situation. Same code as above but replace the if else block with a for loop which pulls a value out of an array at each pass. The array value will be stored in a variable like so:[code]$variable = $_SESSION['array_value'.$i][/code]The $i variable being the array counter.There doesn't seem to be any logical way that i can think of to pull all these variables out of the array before the $message assignment.Can you shed any light?Thank a lot! Quote Link to comment https://forums.phpfreaks.com/topic/26496-complex-sendmail-query/#findComment-121452 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.