473,666 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

1 or more fetch array

ddtpmyra
333 Contributor
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.

Expand|Select|Wrap|Line Numbers
  1. #email process starts here
  2.  
  3.  
  4.         require("class.phpmailer.php");
  5.         $mail = new PHPMailer();
  6.  
  7.         $mail->From     = "xxxx";
  8.         $mail->FromName = "administrator";
  9.         $mail->Subject = "xxxx";
  10.         $mail->Host     = "xx.xx.xx.x"; // SMTP server
  11.         $mail->Mailer   = "smtp";
  12.  
  13.         //$query 
  14.         $query ="SELECT * FROM members";
  15.         $query1 ="SELECT max(fileid) FROM table1";
  16.  
  17.  
  18.         $result=@MYSQL_QUERY($query);
  19.         $result1=@MYSQL_QUERY($query1);
  20.  
  21.         while ($row = mysql_fetch_array ($result, $result1)) {
  22.             // HTML body
  23.             $body  = "Hello <font size=\"4\">" . $row["fname"] . "</font>, <p>";
  24.             $body .= " <font size=\"4\"> A document is now available for your review" . $row["fileid"] ."</font><p>";
  25.             $body .= "http://xx.xx.xx.xxx/data.php?id=\" .$row [fileid] .\"<p>";
  26.             $body .= "Thank You, <br>";
  27.             $body .= "Administrator";
  28.  
  29.  
  30.  
  31.             $mail->Body    = $body;
  32.             $mail->AltBody = $text_body;
  33.             $mail->AddAddress($row["email"], $row["fname"]);
  34.  
  35.             if(!$mail->Send())
  36.                 echo "There has been a mail error sending to " . $row["email"] . "<br>";
  37.  
  38.             // Clear all addresses and attachments for next loop
  39.             $mail->ClearAddresses();
  40.             $mail->ClearAttachments();
  41.         }
  42.  
I know this won't work :) any suggestion how to call two queries?
Jun 16 '09 #1
3 2301
Dormilich
8,658 Recognized Expert Moderator Expert
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)
Jun 17 '09 #2
prabirchoudhury
162 New Member
1.if this two tables are different and have no primary and foreign key relation then you could make this query like..

Expand|Select|Wrap|Line Numbers
  1. SELECT members. * , (SELECT max(fileid) FROM table1) AS max_field
  2. FROM members
  3.  
  4.  
:)
Jun 19 '09 #3
ddtpmyra
333 Contributor
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
@prabirchoudhury
Jun 19 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
5477
by: Brian Tkatch | last post by:
I have a PROCEDURE that test other PROCEDUREs. Timings_Call ------------------ Id Group Name Text Timings_Log
38
3037
by: sopranos2 | last post by:
Dear IBM DB2 support, I wish CLP would have been more functional. Without living the command line I would like to get sql return code explanations, scalar function definitions etc.. Looking forward to see CLP enhancements in v8.3 -mike
1
1336
by: Ben Ellis | last post by:
Hello all, I'm wanting to know which method I should use to fetch dynamic XML data. Is it better to use web services or to fetch the data from a dynamic XML file? Either, use a webMethod to return a byte array of the XML data, or use an ASP page that generates the XML data. Any input would be great, thanks!
7
16703
by: asenthil | last post by:
Hai to all, this is senthil... i'm now working in the field of VC++... i want to connect a mysql database... just now tried to retrieve rows from a simple mysql database by using VC++ My database is like this...
4
2499
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
9
1590
The1corrupted
by: The1corrupted | last post by:
This is truly frustrating. I'm trying to fetch one array from two different tables. Personally, I think it would work but I always get this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Vardaes\more1.php on line 50 Well... here's line 50 and the array fetch just before it. $tablesummon=mysql_query("SELECT * FROM user_table WHERE cn='$user'"); $array=mysql_fetch_array($tablesummon); ...
1
1372
by: buzzw | last post by:
I am trying to find top n salaries from given table . My code returns top n salaries but if there are same value of salaries for more than 1 emp than program just picks one of them, I want to list all of them who has max salaries How can I fetch twice inside a loop with the same cursor . I am trying to fetch a cursor who finds max sal emp names , then I need to fetch it again to find all other emps who has same max sal . thanks cursor...
1
2811
by: yasmine | last post by:
Hi friends, I'm having a table which stores id as comma separated in string datatype. I want to fetch each of the value in a row in the form of array such as follows: table: sid name 2,3,5,7,9... Apple 19,37,46,1... Orange
1
1815
by: dillipkumar | last post by:
Hi, I have a flat file like: 106|4 |ABC|0000000280| 919886046726| 253436| TP001| 1| 4200| 998607230300| 12345630864|BUNDLE| ACE1| | | | 00e142daaf20b965| 99| |13|01|NA|2009-10-20 13:00:05| 110| 110| | 521000|3|N| | PQRS| N| CHARGE| 110| PER_TIME_02| 240| 59992000| 0| ...
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.