dare87 Posted March 28, 2008 Share Posted March 28, 2008 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>'; Quote Link to comment https://forums.phpfreaks.com/topic/98252-solved-contact-all/ Share on other sites More sharing options...
darkfreaks Posted March 28, 2008 Share Posted March 28, 2008 <?php implode(",", $row);?> Quote Link to comment https://forums.phpfreaks.com/topic/98252-solved-contact-all/#findComment-502726 Share on other sites More sharing options...
dare87 Posted March 28, 2008 Author Share Posted March 28, 2008 that really doesn't help me... I don't understand what it does or where to put it. But Thanks... any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/98252-solved-contact-all/#findComment-502836 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 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; ?> Quote Link to comment https://forums.phpfreaks.com/topic/98252-solved-contact-all/#findComment-502905 Share on other sites More sharing options...
dare87 Posted March 28, 2008 Author Share Posted March 28, 2008 I don't see where the comma gets put in? Quote Link to comment https://forums.phpfreaks.com/topic/98252-solved-contact-all/#findComment-503660 Share on other sites More sharing options...
maexus Posted March 29, 2008 Share Posted March 29, 2008 http://us.php.net/implode Read this. Quote Link to comment https://forums.phpfreaks.com/topic/98252-solved-contact-all/#findComment-503964 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.