|
Posted by Tim Streater on 01/02/08 17:37
In article
<19822ae9-b6c1-424a-92b1-cbf5d754d851@x69g2000hsx.googlegroups.com>,
paul814@excite.com wrote:
[snip]
> >
> > > if (mysql_num_rows($result)) { // if there are results
> > > // Add results from first query to email
> > > while($row = mysql_fetch_array(mysql_query($sql))){
> > > $messageBody .= "Editorial Date: " . $row['editorialdate'];
> > > $messageBody .= "/r/n";
> > > $messageBody .= "Editorial Name: " . $row['editorialname'];
> > > $messageBody .= "/r/n";
> > > $messageBody .= "Editorial Comments: " . $row['editorialcomments'];
> > > $messageBody .= "/r/n";
> > > }
> >
> > > // Add results from second query to email
> > > while($row = mysql_fetch_array(mysql_query($sql2))) {
> > > $messageBody .= "PrePress Date: " . $row['prepressdate'];
> > > $messageBody .= "/r/n";
> > > $messageBody .= "Prepress Name: " . $row['prepressname'];
> > > $messageBody .= "/r/n";
> > > $messageBody .= "Prepress Comments: " . $row['prepresscomments'];
> > > $messageBody .= "/r/n";
> > > }
> > > }
> >
> > > mysql_close($con); //closes the connection to the DB
> >
> > > // Send email
> > > ini_set("SMTP", "texchange.company.com");
> > > ini_set("smtp_port", "25");
> > > $headers = "From: Prod.Report_PREPR...@company.com";
> > > mail("p...@company.com","Production Report",$messageBody,$headers);
> > > ?>
> >
> > > And I do get an email, all that is in the email though is:
> > > Production Report follows for all departments: /r/n
>
> so will I need one of these IF statements before each one of my:
> while($row = mysql_fetch_array(mysql_query($sql))){
>
> and then do I also need multiple:
> $result=mysql_query($sql);
> only use $sql2 etc?
If you don't do a query, you won't have any results. If you have two
query strings, you obviously gotta do two queries.
If you got two queries, you got to check each one to see if it returned
any results. Why do you think the first IF which covers the first query,
should also cover the second?
Navigation:
[Reply to this message]
|