Solved

mail a whole mysql query to the recipient obtained from the query

Posted on 2011-03-13
7
279 Views
Last Modified: 2013-12-13
Though I got really good responses to my questions, I still need more...
Please how could I send the whole query to the recipient obtained from the query
I cannot enter the email of the recipient in the script as  the recipient changes according to the query
so far this is what I have done thank to the previous replies you gave me
What I really want is to click send and the whole query is automatically send to the recipient
whose email is on the query results
Thanks for your great help
<h1>Please confirm the reception of this email and the acceptance of the job/s below:<br />Information for</h1> 	 
      <?php
$term = $_POST['term'];
$term1 = $_POST['term1'];

mysql_select_db($database_languageLinks, $languageLinks);
$query_languageLinks = "SELECT * FROM jobs WHERE Job LIKE '%$term%' AND Let LIKE '%$term1%'";
$languageLinks = mysql_query($query_languageLinks, $languageLinks) or die(mysql_error());


while ($row = mysql_fetch_array($languageLinks)){
		
		echo '<br/><b>Job:</b> '.$row['Job'];
			echo '<br/><b>Job Date:</b> '.$row['JobDate'];
	echo '&nbsp;&nbsp;&nbsp; <b>Start at:</b> '.$row['Start'];
		echo '<br/><b>Rescheduled on:</b> ' .$row['2JobDate'];
		echo ' <br/><b>Language:</b> '.$row['Lang'];
	echo '<br/><b>Interpreter:</b> '.$row['FirstName'];
	echo '&nbsp;'.$row['Surname'];
	echo '<br> <b>Agency/Org:</b> '.$row['ClientName'];
			echo '<br> <b>Location:</b> '.$row['JobAdd'];
		echo '<br> <b>For Non English Speaker:</b> ' .$row['NESB'];

	echo '<br> <b>Ref:</b> '.$row['URN'];

	echo '<br> <b>Interpreter Short Notice:</b> '.$row['ShNotCont'];
					echo '<br/> <b>Comment:</b> '.$row['Comment'];
	echo '<br/>';
	echo '<br/>';
	echo '<br/>';
	 echo '<a href="mailto:'.$row['ContEmail'].'">'.$row['ContEmail'].'</a>'; 
	}

Open in new window

0
Comment
Question by:ChristianeGuise
  • 4
  • 3
7 Comments
 
LVL 1

Expert Comment

by:CrAppl
ID: 35124849
You are opening your php tags but not closing it.

What exactly is not working?
0
 
LVL 1

Expert Comment

by:CrAppl
ID: 35124938
Ok, going through your question again, try this:
<h1>Please confirm the reception of this email and the acceptance of the job/s below:<br />Information for</h1> 	 
      <?php
$term = $_POST['term'];
$term1 = $_POST['term1'];

$body="";

mysql_select_db($database_languageLinks, $languageLinks);
$query_languageLinks = "SELECT * FROM jobs WHERE Job LIKE '%$term%' AND Let LIKE '%$term1%'";
$languageLinks = mysql_query($query_languageLinks, $languageLinks) or die(mysql_error());


while ($row = mysql_fetch_array($languageLinks)){
		$body .= " ".$row['Job'];

		echo '<br/><b>Job:</b> '.$row['Job'];
			echo '<br/><b>Job Date:</b> '.$row['JobDate'];

			$body .= " ".$row['JobDate'];

	echo '&nbsp;&nbsp;&nbsp; <b>Start at:</b> '.$row['Start'];

	$body .= " ".$row['Start'];

		echo '<br/><b>Rescheduled on:</b> ' .$row['2JobDate'];

	$body .= " ".$row['2JobDate'];

		echo ' <br/><b>Language:</b> '.$row['Lang'];
	echo '<br/><b>Interpreter:</b> '.$row['FirstName'];
	echo '&nbsp;'.$row['Surname'];
	echo '<br> <b>Agency/Org:</b> '.$row['ClientName'];
			echo '<br> <b>Location:</b> '.$row['JobAdd'];
		echo '<br> <b>For Non English Speaker:</b> ' .$row['NESB'];

	echo '<br> <b>Ref:</b> '.$row['URN'];

	echo '<br> <b>Interpreter Short Notice:</b> '.$row['ShNotCont'];
					echo '<br/> <b>Comment:</b> '.$row['Comment'];
	echo '<br/>';
	echo '<br/>';
	echo '<br/>';
	 echo '<a href="mailto:'.$row['ContEmail'].'?body=$body">'.$row['ContEmail'].'</a>'; 
	}

Open in new window

0
 

Author Comment

by:ChristianeGuise
ID: 35125457
This works as the recipient receives the email but there is nothing in it
except
$body
Anymore idea?
 thank you so so much for helping me
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Expert Comment

by:CrAppl
ID: 35125477
Oops, I missed the single quotes...
I don't test the code as I reply quick :)

You're welcome, the solution below should help you but I still think you are doing this strangely.

Change this line:
 echo '<a href="mailto:'.$row['ContEmail'].'?body=$body">'.$row['ContEmail'].'</a>';

to this:
 echo "<a href=\"mailto:".$row['ContEmail']."?body=$body\">".$row['ContEmail'].'</a>';


 
0
 

Author Comment

by:ChristianeGuise
ID: 35125499
Thank you so much you are a GENIUS
yes it is probably a little strange but I only start with datadase and know so little
if you have a better idea and I am sure you do please let me know
Meanwhile thank you so so much
0
 
LVL 1

Accepted Solution

by:
CrAppl earned 500 total points
ID: 35125541
You're welcome :)

Look into mail()
php.net/mail

you should be able to mail someone automatically instead of using mailto:

If you have problems, create a new question and message me here

Dont forget to award the points before starting the new thread!
0
 

Author Closing Comment

by:ChristianeGuise
ID: 35125663
Yes it was great
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now