...

View Full Version : Any help on formatting with a <hr> or --------- after each item?



student101
08-02-2008, 09:57 AM
Had to change this up a bit, was getting 5 or more even if there was only one.

Where do I put the loop? also which loop? DO while or While do?




// *** Mail form as Text format ***
if (isset($_POST["email"])) {
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db("db1",$db);
$name = trim($HTTP_GET_VARS['name']);
$query=("SELECT * FROM table WHERE name ='$name'");
$result= mysql_query($query);
$num=mysql_num_rows($result);
if ($num > 0) { //Records match
//trim($_POST['email'])
//define the receiver of the email
$to = trim($_POST['email']);
//define the subject of the email
$subject = 'My Wishlist';
//define the message to be sent. Each line should be separated with \n
$message = "My Wishlist"."\n\n";
$message .= "Code: ". $code."\n";
$message .= "Description: ". $description."\n";
$message .= "Diamond info: ". $diamondinfo."\n";
$message .= "Price: ". $price."\n";
$message .= "------------------------";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: ".$to;
//$headers = "From: $to\r\nReply-To: $to";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
//echo $mail_sent ? "Mail sent" : "Mail failed";
}else{
//no send
}
}

infinivert
08-02-2008, 02:08 PM
After:

//define the message to be sent. Each line should be separated with \n
$message = "My Wishlist"."\n\n";
Add something like:

while( $row = mysql_fetch_assoc( $result ) )
{
$message .= "Code: ". $result['code']."\n";
$message .= "Description: ". $result['description']."\n";
$message .= "Diamond info: ". $result['$diamondinfo']."\n";
$message .= "Price: ". $result['price']."\n";
$message .= "------------------------";
}
That is assuming, of course, that your table fields are named code, description, diamondinfo, and price.

--Josh

student101
08-02-2008, 04:00 PM
Wow that worked!

Thank you!!!

After:
That is assuming, of course, that your table fields are named code, description, diamondinfo, and price.
--Josh
These loop fors and while loops always confuse me,
thanks man.

infinivert
08-08-2008, 05:52 AM
No prob. Anytime.

student101
08-08-2008, 06:55 AM
I feel like a god with this HTML email thingy, it's fantastic!!!

Cheers



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum