我做了一个PHP页面,查找数据库中的常量联系人电子邮件地址,并返回一个列出他们的名字,电子邮件地址和邮件列表的表格。您在此输入地址:联系查找工具以及您的常用联系人用户名和密码。PHP邮件数据库搜索
由于某些原因,只有结果页面的最后一行有一个邮件列表列表。其他人有“数组”字样,我删除了,所以现在这些行是空白的。这里是我的意思的屏幕截图:
http://www.advantage-computer.com/images/ScreenCap.png
他们都在列表中,但。这是search.php的代码。该表单提交到该文件:
<!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>
这里是class.cc文件:http://advantage-computer.com/tools/class.cc.txt
尝试使用'print_r'并检查strName和strLists是否为数组。 – 2011-05-29 17:26:10
@ Coding-Freak:谢谢你的回复。当我添加回声(gettype($ strLists));在$ strLists。= $ list之上。 “,”;我得到“布尔字符串字符串”。出于某种原因,即使只有两个电子邮件地址,它也会经历三次循环。 Print_r不会在任何地方打印出“阵列”。 – Richard 2011-05-29 17:36:08
修改这个部分'回声 ( “