This topic is locked

Send Email

11/26/2007 4:02:52 PM
PHPRunner General questions
B
bbanks author

Anyone know how to send an email to everyone on the xxx_list.php page at the same time using a Send email button?
sample code would be very helpful.
Thanks in advance.

J
Jane 11/27/2007

Bart,
you can do the following:

  1. proceed to the Visual Editor tab
  2. turn on HTML mode, find this line:
    <!-- delete form -->

and add following code just before:

<A onclick="if (!confirm('Do you really want to update these records?')) return false; frmAdmin.a.value='update'; frmAdmin.submit(); return false;"

href="TableName_list.htm#">send email</A>


3. proceed to the Events tab and add BeforeDelete event.

Here is a sample code:

function BeforeDelete($where)

{

//delete records

if(@$_POST["a"]=="delete")

return true;
//send email with selected records

global $conn,$strTableName;

$email="test@test.com";

$message="";

$subject="your subject";

$rs = db_query("select * from " . $strTableName ." where ". $where,$conn);
if($data=db_fetch_array($rs))

{

foreach($data as $field=>$value)

$message.= $field." : ".$value."\r\n";

mail($email, $subject, $message);

}

return false;

}

B
bbanks author 11/27/2007

Bart,

you can do the following:

  1. proceed to the Visual Editor tab
  2. turn on HTML mode, find this line:

    and add following code just before:
  3. proceed to the Events tab and add BeforeDelete event.

    Here is a sample code:


Jane,

Thanks for helping but I'm not quite understanding how this should work and could really use some major details on this if you don't mind.
My list page is actually a master/details page and the details list is actually a view from a table so that the records are filtered to only show the list of those people that should get an email.

I end up with about 10 records on the details page that I need to send one email to all of them.
The database is called "Painless"

The master table is called "tblNewProductOutline"

The details view is called "Incomplete Processes" which is based on the table called "tblNewProductFunc"

The field that holds the email addresses is called "PersonResp"
I am completely confussed and would greatly appreciate as much help as you can possible take the time to give me.
Thanks again!

J
Jane 11/28/2007

Bart,
try to use this code in the Before record deleted event:

function BeforeDelete($where)

{

//delete records

if(@$_POST["a"]=="delete")

return true;
//send email with selected records

global $conn,$strTableName;

$message="your message";

$subject="your subject";

$rs = db_query("select * from " . $strTableName ." where ". $where,$conn);

while($data=db_fetch_array($rs))

{

$email=$data["PersonResp"];

mail($email, $subject, $message);

}

return false;

}

B
bbanks author 11/28/2007

Bart,

try to use this code in the Before record deleted event:


Jane,
Is this suppose to work with the delete checkboxes?

I am now getting this error

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 'fromIncomplete Processes where `FuncID`=132' at line 1

J
Jane 11/29/2007

Bart,
this error happens when there are some errors in your SQL query.

Try to print SQL query before executing:

...

echo "select from ".$strTableName." where ". $where;

$rs = db_query("select
from " . $strTableName ." where ". $where,$conn);

...


If it doesn't help you can publish your application on Demo Account and send me link to your pages. I'll find what's wrong with your project inspecting it at Demo account site.

B
bbanks author 11/29/2007

Bart,

this error happens when there are some errors in your SQL query.

Try to print SQL query before executing:
If it doesn't help you can publish your application on Demo Account and send me link to your pages. I'll find what's wrong with your project inspecting it at Demo account site.


I got it and it works great now. Thanks for your help!
here it is:
//delete records

if(@$_POST["a"]=="delete")

return true;
//send email with selected records

global $conn,$strTableName;
$message="There is at least one Process in the New Product Outline that requires your attention."."\n";

$subject="New Product outline";

$rs = db_query("select * from ". $strTableName ." where ". $where,$conn);

while($data=db_fetch_array($rs))

{
$email=$data["PersonResp"];

$message.="Go to the Intranet, Sign in and click on New Product Outline."."\n"."\n";

$message.="Check Part # " . $data["Part"]."\n"."\n";

$message.="http://mysite/~intranet"."\n";

mail($email, $subject, $message);

}

return false;
Jane,
Thanks again!