Grab email addresses in a foreach loop to use in contact form?
<p>Hi after a few hours scratching my head, I have decided to ask for help on this. I have the following code which pulls users from the wordpress database in a foreach loop including their names and email addresses. Im hoping to be able to structure the output so that when you click the enquiry button, it will send an email to the relevent person:</p>

<pre><code>  global $wpdb;
  $results = $wpdb-&gt;get_results("
  SELECT ID, display_name, user_email, meta_value, meta_key FROM wp_users usr
  JOIN wp_usermeta um ON um.user_id = usr.ID
  WHERE um.meta_key = 'wp_capabilities'
  AND um.meta_value LIKE '%outlet%'
  ");

  if(!empty($results)) {
  foreach($results as $r) {  
  echo '&lt;td&gt;' .$r-&gt;display_name. '&lt;/td&gt;
        &lt;td&gt;&lt;button onclick='enquiry_show();'&gt;' .$r-&gt;user_email. '&lt;/td&gt;&lt;/button&gt;';
</code></pre>

<p>So I basically end up with something that looks like:</p>

<p>Display name  | CLICK TO ENQUIRE</p>

<p>which will open a contact form when clicked.</p>

<p>Does anybody know how I can split the email addresses up so that when the contact form shows, I can email the person in relation to the display name?
I currently get one email address as a result when I echo the email address to the contact form.. I would be eternally greatful for any help or advice</p>