goalpie Posted July 19, 2007 Share Posted July 19, 2007 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. Quote Link to comment Share on other sites More sharing options...
benjaminbeazy Posted July 19, 2007 Share Posted July 19, 2007 use php. please post code. Quote Link to comment Share on other sites More sharing options...
goalpie Posted July 19, 2007 Author Share Posted July 19, 2007 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. Quote Link to comment Share on other sites More sharing options...
benjaminbeazy Posted July 19, 2007 Share Posted July 19, 2007 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... } Quote Link to comment Share on other sites More sharing options...
goalpie Posted July 19, 2007 Author Share Posted July 19, 2007 So what is the best way to add numerous rows into the mai message? May have to sit down and rewrite it. Does anyone know of any good tutorials on this subject? Quote Link to comment 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.