Jump to content

Help Mailing Fetch Arry Results


grozanc

Recommended Posts

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);
?>

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.