1 or more fetch array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ddtpmyra
    Contributor
    • Jun 2008
    • 333

    1 or more fetch array

    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.

    Code:
    #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?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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)

    Comment

    • prabirchoudhury
      New Member
      • May 2009
      • 162

      #3
      1.if this two tables are different and have no primary and foreign key relation then you could make this query like..

      Code:
      SELECT members. * , (SELECT max(fileid) FROM table1) AS max_field
      FROM members
      :)

      Comment

      • ddtpmyra
        Contributor
        • Jun 2008
        • 333

        #4
        I have 1.2.13 MYSQL Query Browser

        And I had error when I execute this query. Any idea why?

        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
        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..

        Code:
        SELECT members. * , (SELECT max(fileid) FROM table1) AS max_field
        FROM members
        :)

        Comment

        Working...