0

私はこのPHPコードを持っています:

$number = substr_replace($_POST["number"],"44",0,1);

$sql="SELECT * from channel_did where did LIKE '%".$number."%' AND (client_id = '' OR client_id IS NULL or client_id = '611') AND (extension_id = '' OR extension_id IS NULL) ";
$rs=mysql_query($sql,$pbx01_conn) or die(mysql_error());
while($result=mysql_fetch_array($rs))
{
    $numbers_list = $result["did"].'<br>';
    $email_body = '<font face="Arial">
    Hello, here are some numbers that you have requested.<br><br>
    Please be aware that these numbers are in a public pool and not reservered, therefore they could be assigned to another client at any time.<br><br>
    Please make your choice as soon as possible to guarantee the number you require.<br><br>
    '.$numbers_list.'<br><br>
    Kind Regards,<br><br>
    Customer Services<br>
    Integra Digital<br><br>
    tel: 01702 66 77 27<br>
    email: support@domain.co.uk<br>
    web: www.integradigital.co.uk
    </font>';
}

    echo $email_body;

sendemail($_POST["emailto"],"Integra Digital <no-reply@domain.co.uk>","VoIP Phone Numbers You Requested",$email_body,"no-reply@domain.co.uk");

テーブルから行を選択し、行のリストを含むメールを 1 つだけ送信する必要があります

SQL を実行すると、約 10 行あることがわかります (did)

電子メールを送信するとき、$email_body変数を使用しますが、電子メールに1行しか入れません。

すべての行のリストを持つ変数を作成しました$numbers_listが、1 行しか実行しません。

4

2 に答える 2

6

array() を作成し、行データをそこにプッシュします.. implode()$email_body; で使用します。

これを試して

while($result=mysql_fetch_array($rs))
{
    $numbers_list[] = $result["did"];

}

 $email_body = '<font face="Arial">
    Hello, here are some numbers that you have requested.<br><br>
    Please be aware that these numbers are in a public pool and not reserved, therefore they could be assigned to another client at any time.<br><br>
    Please make your choice as soon as possible to guarantee the number you require.<br><br>
    '.implode('<br>',$numbers_list).'<br><br>
    Kind Regards,<br><br>
    Customer Services<br>
    Integra Digital<br><br>
    tel: 01702 66 77 27<br>
    email: support@integradigital.co.uk<br>
    web: www.integradigital.co.uk
    </font>';

いつものように mysql は非推奨なので、mysqli または PDO を見てください。

于 2013-07-31T12:15:49.493 に答える
0
$number_list = Array();
// no need for unneccesary variables
// no need for unneccesary *, SELECT did
$sql="SELECT did from channel_did 
        WHERE       did LIKE '%".substr_replace(mysql_real_escape_string($_POST["number"]),"44",0,1)."%' 
        AND (   client_id = '' 
            OR  client_id IS NULL 
            OR  client_id = '611'
            ) 
        AND (   extension_id = '' 
            OR  extension_id IS NULL
            ) ";
$rs=mysql_query($sql,$pbx01_conn) or die(mysql_error());
while($result=mysql_fetch_array($rs))
{
    $numbers_list[] = $result["did"].'<br>';

}
 $email_body = '<font face="Arial">
    Hello, here are some numbers that you have requested.<br><br>
    Please be aware that these numbers are in a public pool and not reservered, therefore they could be assigned to another client at any time.<br><br>
    Please make your choice as soon as possible to guarantee the number you require.<br><br>
    '.implode(',',$numbers_list).'<br><br>
    Kind Regards,<br><br>
    Customer Services<br>
    Integra Digital<br><br>
    tel: 01702 66 77 27<br>
    email: support@integradigital.co.uk<br>
    web: www.integradigital.co.uk
    </font>';
echo $email_body;
于 2013-07-31T12:17:59.370 に答える