Web server - If anyone was subscribed to that mailing list,
If anyone was subscribed to that mailing list, you must delete those subscriptions, too: $sql = DELETE FROM ml_subscriptions . WHERE ml_id= . $_POST[ ml_id ]; mysql_query($sql) or die( Could not delete mailing list subscriptions. . mysql_error()); break; When you send a message, you want to let the user know which mailing list you are referring to. If the mailing list ID (ml_id) is all instead of a number, you will want to reflect that as well: case Send Message : if (isset($_POST[ msg ], $_POST[ ml_id ])) { if (is_numeric($_POST[ ml_id ])) { $sql = SELECT listname FROM ml_lists . WHERE ml_id= . $_POST[ ml_id ] . ; $result = mysql_query($sql, $conn) or die(mysql_error()); $row = mysql_fetch_array($result); $listname = $row[ listname ]; } else { $listname = Master ; } What follows is a more complicated SQL statement than you ve written thus far, but not too difficult. What s happening here is that you are grabbing the e-mails, first names, and user IDs from the ml_users table where the mailing list ID (ml_id) matches their user ID in the ml_subscriptions table. You do this by using the INNER JOIN command in SQL. You also must not send any e-mails or newsletters to those that are awaiting subscription confirmation, so select only those where pending = 0, or false. If pending = 1 (true), then that row is ignored. $sql = SELECT DISTINCT usr.email, usr.firstname, usr.user_id . FROM ml_users usr . INNER JOIN ml_subscriptions mls . ON usr.user_id = mls.user_id . WHERE mls.pending=0 ; If the administrator did not choose all in the select list, you must limit your selection to the specific users that are subscribed to the mailing list the administrator selected. You do this by tacking on the AND condition: if ($_POST[ ml_id ] != all ) { $sql .= AND mls.ml_id= . $_POST[ ml_id ]; } Now execute the previous SQL statement, and return the results: $result = mysql_query($sql) or die( Could not get list of email addresses. . mysql_error()); 495 Mailing Lists
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.