Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

Multiple table data in email

$
0
0
So I have a form where a logged in user submits some data. I'm trying to use one $_SESSION variable to query an array of data to use in the email. For example, the SESSION data has their account number in it. Using that, I can reference 2 other tables that have the account_id in it for other data, such as address in 1 table, and contact information and name in another table. I tried the following 2 codes without success. Each one will echo the data in a code snippet, but will not show the data in the email:


The first one I tried to store the data in a SESSION, reference the SESSION in the email, and unset the session at the end with it not working:

$rs = DB::Query("SELECT account_data.ownername, account_data.email, account_data.phone, unit_data.address FROM account_data
LEFT OUTER JOIN unit_data ON account_data.address = unit_data.unit WHERE account_data.id = '".$_SESSION["account_id"]."'");
while( $data = $rs->fetchAssoc()){

$data["address"]   = $_SESSION["mailaddress"]; 
$data["ownername"] = $_SESSION["ownername"]; 
$data["email"]     = $_SESSION["email"];
$data["phone"]     = $_SESSION["phone"];
}


That didn't work, so I went to the next option, DBLookup:

$data = DBLookup("SELECT account_data.ownername, account_data.email, account_data.phone, unit_data.address FROM account_data
LEFT OUTER JOIN unit_data ON account_data.address = unit_data.unit WHERE account_data.id = '".$_SESSION["account_id"]."'");


Then I tried to reference $data["fieldvalue'] within the email, and it was still blank.

The only way I was able to get it to work was to create individual DBLookup's, but I would prefer to have 1 instead of multiple lookups to reduce the load on the server. This is what I have that works right now:

$name = DBLookup("SELECT displayname FROM website_users WHERE id = ".$_SESSION["user_id"]."");
$phone = DBLookup("SELECT phone FROM account_data  WHERE id = ".$_SESSION["account_id"]."");
$addresa = DBLookup("SELECT address FROM unit_data     WHERE account_id = ".$_SESSION["account_id"]."");
$sendemail = DBLookup("SELECT email FROM website_users WHERE id = ".$_SESSION["user_id"]."");


I was wondering if there were any other options to make it into 1 query instead of 4.

Viewing all articles
Browse latest Browse all 2586

Trending Articles