Jump to content

[SOLVED] contact all


dare87

Recommended Posts

Right now I have a statement that will pull all the emails from my table users. I was wondering if there is an easy way to do an all and have the spearated by a comma. aka

name1, name2, name3, ...... so on

 

<select class="required" name="emails">
<option value="NAME1, NAME, NAME3, BLAH BLAH BLAH">ALL</option>';
// Retrieve all the names and add them to the pull-down menu.
require_once('../../pimysql_connect.php');
$query = "SELECT txt, first FROM users WHERE txt IS NOT NULL ORDER BY name ASC";
$results = @mysql_query ($query);
while ($row = mysql_fetch_array ($results, MYSQL_NUM))
echo '<option value="' . $row[0] . '">' . $row[1] . '</option>\n';
echo '</select>';

Link to comment
https://forums.phpfreaks.com/topic/98252-solved-contact-all/
Share on other sites

The easier way to do this would be to just use an option like this:

 

<option value="ALL_ENTRIES">ALL</option>'

 

Then do something like this

 

<?php

if ($_POST['emails'] == 'ALL_ENTRIES')
  $where = '1=1'; // selects all users
elseif ( * validate/sanitize $_POST['emails'] to prevent injection * )
  $where = '`txt` = \''.$_POST['emails'].'\' LIMIT 1'; // selects a specific user

$query = 'SELECT `first`, `email` FROM `users` WHERE ' . $where;


?>

Link to comment
https://forums.phpfreaks.com/topic/98252-solved-contact-all/#findComment-502905
Share on other sites

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.