grozanc Posted March 9, 2008 Share Posted March 9, 2008 Hello All, I'm new to all this and have run into a problem I can't figure out or find any resources/help when I do searches. I have a page where users can go and retrieve several different entries from the database. I can get the results to display on the screen via echo. However, I want the results emailed and the most I can manage is to get one row of results not all of them. How can I get the results of the query displayed in the body of the email message? Any help or pointing in the right direction would be appreciated. You can see the code below. <form method="POST" action=""> <font class="forms">Enter Email Address:</font> <input type="text" name="email" class="story"><br><br> <input type="submit" value="retrieve" class="btn"><br><br> </form> </font> <? if($_SERVER['REQUEST_METHOD'] == 'POST') { $host = 'localhost'; $user = 'xxxxxx; $pass = 'xxxxxx'; $db = 'xxxxxx'; mysql_connect($host,$user,$pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); $email=$_POST['email']; $query = "SELECT first_name, entry_type, entry_id, password FROM uploads_entryid WHERE email = '$email'"; $result = mysql_query($query) or die('Error, query failed'); while(list($first_name, $entry_type, $entry_id, $password) = mysql_fetch_array($result)) echo "Hello $first_name,<br><li>$entry_type:<br>Entry ID: $entry_id<br>Password: $password</li>"; } ?> <?php // Email Username, Password and Story ID $to = "$email"; $from = "xxxxxx"; $subject = "Your Pavement Memoirs Username & Password"; $message = <<<EOF <html> <body> Hello $first_name,<br> <br> Thank you for your submission! Feel free to use the following entry id’s, and passwords when logging in to Pavement Memoirs to make adjustments to your post. <br><br> <br><br> Keep in mind each time you edit your post, the new submission will not be viewable until it’s reviewed to keep the site PG rated. <br><br> </body> </html> EOF; $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to, $from"; mail($to, $subject, $message, $headers); ?> 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.