note 55951 deleted from function.substr by bobby

From: Date: Thu, 14 Sep 2006 17:40:57 +0000
Subject: note 55951 deleted from function.substr by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117182@lists.php.net to get a copy of this message
Note Submitter: concordia at jusgoo dot farvista dot net ---- You can use PHP substr() along with MySQL to make mailstrings. <?php require ('../mysql_connt.php'); // Connect to MySQL. Assuming the connection works and there are no errors. $mail_string = NULL; // Initialize the variable. $query = 'SELECT email FROM users'; // Select e-mail from users. $result = mysql_query ($query); // Submit the query. if ($result) { // If the resource result is provided. while ($row = mysql_fetch_array ($result, MYSQL_NUM)) { $mail_string .= '<a href="mailto:' . $row[0] . '">' . $row[0] . '</a>, '; // Concat. the e-mails to the mail string. } echo substr ($mail_string, 0, -2); // Trim off the final comma and space then echo it. } ?> This will create a mailstring like this: email1@domain.com, email2@domain.com, email3@domain1.com

« previous php.notes (#117182) next »