RE: [PHP-WIN] Query within Mail Function

From: Date: Tue, 20 Aug 2002 16:47:43 +0000
Subject: RE: [PHP-WIN] Query within Mail Function
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-15366@lists.php.net to get a copy of this message
<? $sql = mysql_query("select * from table") or die ("error"); $body = ""; while ($row = mysql_fetch_array($sql)) { $body .= $row['name']." - ".$row['email']." - ".$row['age']."\n"; } mail ($to_mail, $subject, $body); ?> Ross PS Just as an added bonus tip: Don't store an age in a database. I'm 21 now, but won't be in a month. Store a dob and calculate it from that > -----Original Message----- > From: James Meers [mailto:jambo@venda.com] > Sent: 20 August 2002 13:32 > To: php-windows@lists.php.net > Subject: [PHP-WIN] Query within Mail Function > > > Hi, > > Please bear with my limited knowledge of PHP... > > Does anyone know if it is possible to code a sql query within the > message part of the mail function, e.g.: > > mail( "$to_mail","$sumject"," > > $sql = mysql_query("select * from table") > or die("error with query\n"); > > while ($row = mysql_fetch_array($sql)) { > $db_name=$row["name"]; > $db_email=$row["email"]; > $db_age=$row["age"]; > > echo"$name - $email - $age"; > > } > > " ); > > This obviously is wrong, does anyone know if its possible, if so, > what is the right way of writing it?? > > Cheers > > James >

« previous php.windows (#15366) next »