PHP Mailing List Mail Search

I made a PHP page that looks at the permanent contact email addresses in the database and returns a table showing their name, email address and the mailing list in which they are located. Here you enter the addresses: Contact Lookup Tool along with your permanent username and password.

For some reason, only the last line of the results page has a list of mailing lists. Others have the word "Array" that I deleted, so now these lines are empty. Here is a screenshot of what I mean:

http://www.advantage-computer.com/images/ScreenCap.png

They are all listed. Here is the code for search.php. The form is submitted to this file:

<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <title> List of Contacts </title>
        <style type = "text / css">
            .hdr
            {
                margin-bottom: 0px;
                padding-bottom: 0px;
            }
        </style>
    </head>
    <body>
        <table width = "75%">
            <tr>
                <td class = "hdr"> Name </td>
                <td class = "hdr"> E-mail address </td>
                <td class = "hdr"> List (s) </td>
            </tr>
            <tr>
                <td colspan = "3">
                    <hr style = "padding: 0; margin: 0">
                </td>
            </tr>
            <? PHP
                require_once ('./ class.cc.php');

                / * VARIABLES * /
                $ cc = new cc ($ _ POST ['userName'], $ _POST ['password']);
                if ($ cc)
                {
                    $ strEmails = $ _REQUEST ['emails'];
                    $ aryEmails = explode ("\ n", $ strEmails);

                    $ page = (isset ($ _ GET ['page']))? $ _GET ['page']: 'lists';
                    $ lists = $ cc-> get_lists ($ page);

                    / * METHODS * /
                    foreach ($ aryEmails as $ email)
                    {       
                        if ($ lists)
                        {
                            foreach ($ lists as $ k => $ v)
                            {
                                $ list = $ v ['Name'];
                                $ page = (isset ($ _ GET ['page']))? $ _GET ['page']: 'members';
                                $ members = $ cc-> get_list_members ($ v ['id'], $ page);

                                if ($ members)
                                {
                                    foreach ($ members as $ k => $ v)
                                    {
                                        if ($ v ['EmailAddress'] == $ email)
                                        {
                                            $ strLists. = $ list. ",";
                                        }
                                    }
                                }
                            }
                        }

                        $ strLists = str_replace ("Array", "", $ strLists);
                        $ strLists = substr ($ strLists, 0, -2);

                        $ contact = $ cc-> query_contacts (trim ($ email));

                        if ($ contact)
                        {
                            $ strName = $ contact ['Name'];
                            if (is_array ($ strName))
                            {
                                $ strName = "";
                            }

                            echo
                            (
                                "<tr> <td>". $ strName. "</td>".
                                "<td>". $ contact ['EmailAddress']. "</td>".
                                "<td>". $ strLists. "</td> </tr>"
                            );
                        }

                        else
                        {
                            echo ("<tr> <td colspan = '3'> Could not find {$ email}. </td> </tr>");
                        }
                    }
                }

                else
                {
                    echo "Invalid user name or password";
                }
            ?>
        </table>
    </body>
</html>

Here is the class.cc file: http://advantage-computer.com/tools/class.cc.txt

+3
source share
2 answers

Thanks to everyone for the answers. My brother found a problem. He changed

foreach ($aryEmails as $email){
    ...
}

to

foreach ($aryEmails as $tmpEmail){ 
    $email = rtrim($tmpEmail);
    ...
}

, , , , . rtrim, .

0

-, , , $k, , :

if($members)
  foreach($members as $v)
    if($v['EmailAddress'] == $email)
    {
      $strLists .= $list . ", ";
      break;
    }

Whats $list, :

if (is_array($list))
  var_dump($list);

, , "$ _list ['content'] ['ContactList'] ['Name']" , .

+1

All Articles