trying to create a Class!
Posted: Mon Jul 26, 2010 9:56 am
Hello, again php Technorati. Ok, I am attempting to create my first class app that will send out an email when the user selects "Yes". The app will check if the user selected yes first, match the $category to the Mysql categories(cat_1 to cat_5) that are already in the database. If they match, email will be sent!
Here is my flawed attempt at creating this class:
1) cat_1 to cat_5 is already in the database with saved categories. I need make sure that if any one of them is equal to $category, then the email will be sent! I tried to use an associative array, but I am not sure if this is the correct way to perform this task. Nor am I sure if my method function is correct. Can someone enlighten me on the efficient way of creating a class that will perform this function!
Thanks in advance!
Batoe
Code: Select all
class Send_port{
public $activate_res = $_POST['activate_res'];
public $category = $info['category'];
public $portID = $info['portID'];
public $indust = array ('cat_1' => $category,
'cat_2' => $category,
'cat_3' => $category,
'cat_4' => $category,
'cat_5' => $category );
function ($activate_res){
switch ($activate_res)
case 'Yes';
$query = "SELECT * FROM mail WHERE '$indust' = '$category'";
$result = mysql_query($query) or die (mysql_error());
while($row = mysql_fetch_assoc($result))
{
$message = "Hello, ";
mail($row['email'], "Whats up!", $message, "From: Batoe" );
}
break;
case 'No';
break;
}
}Thanks in advance!
Batoe