Jump to content

Populating an external DB into an e-mail


turkeyslyr

Recommended Posts

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";
   }
?>

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>

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.