Jump to content

writting an email script


goalpie

Recommended Posts

Hi all. I have returned a set of results from a database in a form which I want to post to an email script. I can only get one row to show up in the email even though the result in the form shows up the results and places them in text boxes.

 

Obviously I am going about this the wrong way. Any suggestions on the best way to pass numerous rows of results into an email script.

Link to comment
Share on other sites

I have edited bits as it

 

htm page

 

to get my results i have joined the two databases

 

mysql_select_db($database_myConn, $myConn);

$query_getItem = "select * FROM cart INNER JOIN Product ON cart.itemId = Product.itemId WHERE `cookieId` = '" . GetCartId() . "'";

$getItem = mysql_query($query_getItem, $myConn) or die(mysql_error());

$row_getItem = mysql_fetch_assoc($getItem);

$totalRows_getItem = mysql_num_rows($getItem);

 

I wanted to name the repeating form text box so I set up a variable

 

$data = "storeitem";

 

<input name="<?php echo $data; ?>" type="text" value="<?php echo $row_getItem['cookieId']; ?><?php echo $row_getItem['title']; ?>" multipal="multipal">

 

Then it goes to the email validation page

 

<?php require_once('../Connections/myConn.php'); ?>

<?PHP

print "Thank you $_POST[firstname] for your order.<BR><BR>\n\n";

print " <BR><BR>\n\n";

print " <BR><BR>\n\n";

print " <BR><BR>\n\n";

//Start Building Mail String

//$msg .= "storeitem: $row_Recordset1[title]\n";

$msg .= "storeitem: $_POST[storeitem]\n";

$msg .= "totalprice: $_POST[totalprice]\n";

$msg .= "title: $_POST[title]\n";

$msg .= "firstname: $_POST[firstname]\n";

$msg .= "lastname: $_POST[lastname]\n";

$msg .= "streetaddress: $_POST[streetaddress]\n";

$msg .= "state: $_POST[state]\n";

$msg .= "postcode: $_POST[postcode]\n";

$msg .= "phone: $_POST[phone]\n";

$msg .= "mobile: $_POST[mobile]\n";

$msg .= "email: $_POST\n";

//echo "$msg";

//set up email

$recipient = "blah@blah.com";

$subject = "XXXX Gifts";

$mailheaders = "From: $_POST \n";

$mailheaders .= "Reply-To: $_POST";

//send email

mail($recipient, $subject, $msg, $mailheaders);

?>

 

I am looking for a better way of building an email as this won't work. Only returns the last row of reults in my final email.

Link to comment
Share on other sites

i'm not sure exactly how you're posting all of the variables from each query result row to a new script... that doesn't make sense to me

 

you need your query in the same script as your message variable definition

 

to construct, you need to iterate through each of the query results via a while loop

 

while($row_getItem = mysql_fetch_assoc($getItem)){

 

    $msg.= "price: {$row_getItem['price']}\n";

 

    etc...

 

 

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.