Thank you guys for the reply. Worked on it and made some significant progress. It's now looping through the specified variables properly, however it is giving me "undefined variable" errors as it does so.
I figure it's just a matter of me not properly defining a variable somewhere, but again, still struggling to figure this all out.
Here's the new code:
_email_template.php
<?
include("EmailTemplate.class.php"); // Email Template Class
$etmp = new EmailTemplate(1);
$etmp->setParam('FirstName',John);
$etmp->setParam('LastName','Smith');
$etmp->setParam('PurchasePrice','$9.95');
//$etmp->name="FirstName";
//$etmp->value="John";
print $etmp->getText();
?>
EmailTemplate.class.php
<?
ini_set('display_errors', 1); // turn off for production version
error_reporting(E_ALL);
class EmailTemplate {
var $params;
var $name;
var $value;
var $fields=null;
var $text=null;
function LoadEmailTemplate($templateID){
// FIND AND CREATE THE ARRAY OF FIELDLIST ENTRIES
//set up table and database names
$db ="dbname";
$sql = "
SELECT
*
FROM
email_templates
WHERE
ID='$_GET[templateID]'
ORDER BY
Name
";
$result = @mysql_query($sql,$connection)or die(mysql_error());
if($row=$recordset->FetchRow()){
$this->$fields=preg_split('/|/',$row['FieldList'], -1, PREG_SPLIT_NO_EMPTY);
} else {
trigger_error('Invalid Email Template ID',E_USER_NOTICE);
}
}
function setParam()
{
$this->params[$name]=$fields;
return $this->value=$params;
}
function getText()
{
// this should be the function that find the proper text value and prints it
return "<b>" .$this->name. "</b> : " .$this->value. "<br>";
}
} // end class
?>
This is the error I'm recieving (lines 39 and 40 refer to the setParam function in the code above:
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 39
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 39
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 40
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 39
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 39
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 40
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 39
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 39
Notice: Undefined variable: name in website.com\site\modules\email_templates\EmailTemplate.class.php on line 40
Thank you again for any help!! It's very much appreciated