1 or more fetch array 
June 17th, 2009, 12:15 AM
|  | Familiar Sight | | Join Date: Jun 2008 Location: CA
Posts: 204
| |
I have two separate query on my PHP mailer and I wonder how can it be possible to call the two queries in one fetch array. - #email process starts here
-
-
-
require("class.phpmailer.php");
-
$mail = new PHPMailer();
-
-
$mail->From = "xxxx";
-
$mail->FromName = "administrator";
-
$mail->Subject = "xxxx";
-
$mail->Host = "xx.xx.xx.x"; // SMTP server
-
$mail->Mailer = "smtp";
-
-
//$query
-
$query ="SELECT * FROM members";
-
$query1 ="SELECT max(fileid) FROM table1";
-
-
-
$result=@MYSQL_QUERY($query);
-
$result1=@MYSQL_QUERY($query1);
-
-
while ($row = mysql_fetch_array ($result, $result1)) {
-
// HTML body
-
$body = "Hello <font size=\"4\">" . $row["fname"] . "</font>, <p>";
-
$body .= " <font size=\"4\"> A document is now available for your review" . $row["fileid"] ."</font><p>";
-
$body .= "http://xx.xx.xx.xxx/data.php?id=\" .$row [fileid] .\"<p>";
-
$body .= "Thank You, <br>";
-
$body .= "Administrator";
-
-
-
-
$mail->Body = $body;
-
$mail->AltBody = $text_body;
-
$mail->AddAddress($row["email"], $row["fname"]);
-
-
if(!$mail->Send())
-
echo "There has been a mail error sending to " . $row["email"] . "<br>";
-
-
// Clear all addresses and attachments for next loop
-
$mail->ClearAddresses();
-
$mail->ClearAttachments();
-
}
-
I know this won't work :) any suggestion how to call two queries?
| 
June 17th, 2009, 05:26 AM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9 | | | re: 1 or more fetch array
you need to combine the two queries, so that you fetch all data at once. I think this can be done using the JOIN syntax (although the SQL people might know better)
| 
June 19th, 2009, 08:14 AM
|  | Familiar Sight | | Join Date: May 2009 Location: Wellington, New Zealand
Posts: 152
| | | re: 1 or more fetch array
1.if this two tables are different and have no primary and foreign key relation then you could make this query like.. -
SELECT members. * , (SELECT max(fileid) FROM table1) AS max_field
-
FROM members
-
-
:)
| 
June 19th, 2009, 03:58 PM
|  | Familiar Sight | | Join Date: Jun 2008 Location: CA
Posts: 204
| | | re: 1 or more fetch array
I have 1.2.13 MYSQL Query Browser
And I had error when I execute this query. Any idea why? Quote:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT max(fileid) FROM table1) AS max_field
FROM members' at
| Quote:
Originally Posted by prabirchoudhury 1.if this two tables are different and have no primary and foreign key relation then you could make this query like.. -
SELECT members. * , (SELECT max(fileid) FROM table1) AS max_field
-
FROM members
-
-
:) | |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|