Re: [PHP] looping through a $_POST variable



I am trying to get one email at a time and run it through the loop and process it but if I have more than one email in the text area it gives me nothing and does not run
What kind of problems are you having in extracting the data?

On Dec 30, 2007, at 4:29 PM, Richard Kurth wrote:

I am trying to loop through a $_POST variable. It comes from a text area and it will have data like many email address or just one listed with a space or on a new line. I can't seam to get the data to extract properly. I have tried this below

$array = explode(' ', $_POST['emails']);
foreach ($array as $value) {
$sql = "SELECT id FROM contacts where emailaddress = '$value' AND members_id = '$memberid'";
$sql_result=safe_query($sql);
while ($row=mysql_fetch_array($sql_result)){
$id = $row["id"];
$sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id = '$id'";
safe_query($sql1);
}}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



.



Relevant Pages

  • RE: [PHP] EZ array problem - Whats wrong with my brain?
    ... EZ array problem - What's wrong with my brain? ... Brian Dunning skrev: ... To unsubscribe, visit: http://www.php.net/unsub.php ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] foreach question
    ... Even though the user should be separating the lines with a line break, this turns into one long string with line breaks in it, not separate array elements. ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] foreach question
    ... A textarea does not produce an array. ... should be separating the lines with a line break, ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] convert query result to array
    ... fetchAll() works if php version is greater than 5. ... Store earch rows of the resultset in the array. ... > PHP General Mailing List ... > To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • RES: [PHP] Get array as string --Help
    ... Get array as string --Help ... How can I convert this array into a string? ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)