bradkenyon Posted September 25, 2006 Share Posted September 25, 2006 I have a simple table setup, which I have 2 or 3 email addresses stored in the one field table, table titled email, and field titled email.I want to pull the emails from the table and put it in a input type box, as its value.For example: <input type="text" name="to" value="$email">I don't know exactly how do this, currently I have it going into the text box, like explained above, but it is outputting a different text box for each email. I just want it all in the same text box, example:[email protected], [email protected], [email protected]This would be what I want, just like you would send an email to multiple people, separating the different emails by commas in the "to:" field of an email.[code]<?php // Make a MySQL Connection mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); // Get all the data from the "email" table $result = mysql_query("SELECT * FROM email") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Email</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<input type=text value=$row[email]>"; } echo "</table>"; ?>[/code]This is what I have currently, which will output a text box for each email, instead of that, I just want one text box, with all the emails in it, separated by commas.Thanks in advanced. Link to comment https://forums.phpfreaks.com/topic/22043-solved-pulling-email-field-out-of-database-table-into-email-to-field/ Share on other sites More sharing options...
trq Posted September 25, 2006 Share Posted September 25, 2006 [code=php:0]$c = 1;while($row = mysql_fetch_array( $result )) { if ($c == 1) { $emails = $row['email']; } else { $emails .= ', '.$row['email']; } $c++;}echo "<input type=text value=\"$emails\">";[/code] Link to comment https://forums.phpfreaks.com/topic/22043-solved-pulling-email-field-out-of-database-table-into-email-to-field/#findComment-98597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.