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
https://forums.phpfreaks.com/topic/60688-writting-an-email-script/
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 = "[email protected]";

$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.

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...

 

 

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.