Jump to content

help with an array to variable for php emailer


RyanSF07

Recommended Posts

Hi Guys,

 

I'm trying to create an emailer for a teacher to use to email all of the students who have joined his/her class.

 

The students have joined the online version of the teachers class by filling out a form indicating who their teacher is, the name of the class, their name, and their email address.

 

The teachers have several classes.

 

Ideally, to email everyone in a particular class, the teacher could select the class from a drop down menu.

 

How can I assign all of the email address of the students in a class to a variable, so that when the class is selected from the drop down, it corresponds to a variable that represents the contact info for the whole class?

 

Currently what I have lists all of the classes -- I'm stuck now on how to have the selected class in the dropdown menu correspond with the "contact_class" variable.

 

All ideas greatly appreciated -- Thank you very much for your help!

 

$query ="SELECT * FROM registered_users, classes WHERE registered_users.teacher_code = classes.teacher_teachercode AND registered_users.id = $_SESSION[user_id]";
$query_result3 = mysql_query($query);

while ( $row3 = mysql_fetch_array ($query_result3)){
$options .= '<option value="'.$row3['class_id'].'">'.$row3['class_id'].'</option>';
$_SESSION[email] = $row3[email];
}

$form = <<<EOD

<form action = "contact_class_process.php" method = "post">
<table width="450">
<tr>
<td class = "left"><p><b>To Everyone in:</b></p></td>
<td class = "right"><select>$options</select>
</td>
</tr>
<tr>
<td class = "left"><p><b>From:</b></p></td>
<td class = "right"><p>$_SESSION[name] :: $_SESSION[email]</p> </td>
</tr>

::

$contact_class = The $variable that represents everyone in the class selected in the dropdown

::

mail($contact_class,$subject,$message,$headers);

::

This is all new to me : )

 

I'm going to try breaking this mailing process into two steps. The first step the user will only select the class from the "Select Class" drop drop down. In the next step I'll try to pull the corresponding email addresses using $_REQUEST['Select Class']; in the query.

 

other ideas welcome

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.