Jump to content

array not displaying in textarea ......


anoopd

Recommended Posts

hi,

 

      I am trying to show email ids from db to a textarea but only the last selected value is being shown ... can somebody figure it out what went wrong ...

echo '<h3>Send Mail</h3>'; 
echo '<form action="" method="post"> 
<p><label>To:</label><textarea cols="100" rows="5" name="addresses" readonly>'.$email.'</textarea></p> 
<p><label>Subject:</label><textarea cols="100" rows="1" name="subject" ></textarea></p> 
<p><label>Subject:</label><textarea cols="100" rows="20" name="body" ></textarea></p> 
<p><input type="submit" value="send mail"><input type="reset" value="cancel"></p> 
</form>'; 
?>

 

 

Think there is a problem with giving $email instead of an array ..

There are two buttons for sending mail ..... One to send single mail and the other to send mails to multiple addresses ...

echo '<form id="admin" action="./sendMail.php" method="post">'; 
echo '<table>'; 
while($row=mysql_fetch_assoc($result)) 
            { 
              echo'<tr ><td>'.$i++.' </td><td><input type="checkbox" name="edit[]" value='.$row['id']. '></td><td>'. $row['email'] . '</td><td>'. strtolower($row['fname'] ." ". $row['lname']) . ' </td><td>'; 
echo '</a> </td><td><a href="sendMail.php?id='.$row['id'].'"><img src="images/mail.png"></a></td>'; 
echo '</table>'; 
            echo '<button class="noborder" type="submit" name="submit_mult" value="mail"><img src="images/mail.png"></button></br> '; 
            echo '</form>'; 

 

sendMail.php

 

if (isset($_REQUEST['submit_mult'])) 
{ 
       
      if(count($_POST[edit])>0) 
          { 
             foreach($_POST[edit] as $row[id]) 
               { 
                $sql="select email from users where users.id = $row[id]"; 
                 
               if( mysql_query($sql)) 
                $row=mysql_fetch_row(mysql_query($sql)); 
                echo $email=$row[0].","; 
             
             
                }             
            $email ="Mails"; 
          } 
      else 
        { 
          $email= "No Mail selected"; 
        }        
} 
else{ 
$sql="select email from users where users.id=$_REQUEST[id]"; 

$row=mysql_fetch_row(mysql_query($sql)); 
$email= $row[0]; 
} 
include 'mailForm.php'; 

 

 

When i click to get single mail id it is working nice ...

I am getting comma separated values in the array while selecting multiple mails too when i echo $email in sendmail.php (though there is a comma at the end  ) .. .. but i cant display them in textarea ... can anybody suggest how to handle this .. to display an array in text area ... Thanks in advance for any help and time you spend ....

Link to comment
https://forums.phpfreaks.com/topic/178903-array-not-displaying-in-textarea/
Share on other sites

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.