turkeyslyr Posted July 8, 2009 Share Posted July 8, 2009 I am attempting to populate an external file (data base) into a email. Not quite sure how to get all the names to populate. Any suggestions??? Currently I get the last name only. Here is my code. <?php $file = 'people.txt'; $lines = file($file); foreach ($lines as $value => $line) { $firstname = strtok($line, ' '); } if ($_POST['names']=='y'){ for ($i=0;$i<count($line);$i++) $msg.= "\n- $line"; echo "$line: Yes\n"; } else{ echo "$line: No\n"; } ?> Quote Link to comment Share on other sites More sharing options...
WolfRage Posted July 8, 2009 Share Posted July 8, 2009 Why is count a function and where is it defined? Basicly you should be using a variable there. Quote Link to comment Share on other sites More sharing options...
turkeyslyr Posted July 8, 2009 Author Share Posted July 8, 2009 Would something like this work better to get it to post into an e-mail?? The bottom code is how I am bringing in the external file and populating the checkboxes but when I send the e-mail I only get one name. The bottom name to return. Not the whole list. I thought I could grab $line and post the out come but something isn't right. $line = (isset($_POST['names'])) ? "$line: Yes" : "$line: No"; <td> <?php $file = 'people.txt'; $lines = file($file); foreach ($lines as $value => $line) { $firstname = strtok($line, ' '); echo "<input type='checkbox' name=\'names[]\' value=\'y\'> $line<br />\n"; } ?> <br /> </td> Quote Link to comment 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.