0

$update_email呼び出されたPHP変数を設定し、 2つの異なるテーブルから選択してその変数にデータを追加するコードを実行しています。

ここに私が持っているものがあります:

$update_email='<font face="Calibri">';

    $update_email.='<font color="#999999">## - Please type your reply above this line - ##</font>
    <br><br>
    Your Support Ticket (#'.$_POST["ticketnumber"].') has been updated. You can reply to this email or click the link below to respond.
    <br><br>
    <a href="http://www.domain.co.uk/customer/tickets/viewticket.php?seq='.$_POST["ticketnumber"].'">http://www.domain.co.uk/customer/tickets/viewticket.php?seq='.$_POST["ticketnumber"].'</a>
    <hr />
    <br>';

    $update_email.='<strong>'.$_SESSION["domain.co.uk"]["forename"].' '.$_SESSION["domain.co.uk"]["surname"].' | Technical Support</strong>
    <br>
    '.date("d F Y G:H").'
    <br><br>
    '.nl2br($_POST["ticket_update"]).'
    <br><br>
    <hr />';

    //select all the updates from the ticket_updates table
    $sql="SELECT * from ticket_updates where ticket_seq = '".$_POST["ticketnumber"]."' order by datetime ASC";
    $sql=mysql_query($sql,$conn);
    while($result=mysql_fetch_array($rs))
    {
        //check if its a customer update or Integra update
        if($result["customer"] == 'Yes')
        {
            //get the company(customer) information
            $sql2="SELECT * from tickets where ticketnumber = '".$result["ticket_seq"]."' ";
            $rs2=mysql_query($sql2,$conn);
            $ticket2=mysql_fetch_array($rs2);
            //now select the customer information
            $sql3="SELECT * from customer where sequence = '".$ticket2["company"]."' ";
            $rs3=mysql_query($sql3,$conn);
            $customer2=mysql_fetch_array($rs2);

            $name_text = $customer["company"];
        }
        else
        {
            $name_text = 'Technical Support';
        }

        //set the right date/time format
        $update_time = strtotime($result["datetime"]);
        $update_time = date('d F Y G:H', $update_time);

        $update_email.='<strong>'.$result["updatedby"].' | '.$name_text.'</strong>
        <br>
        '.$update_time.'
        <br><br>
        '.nl2br($result["notes"]).'
        <br><br>
        <hr />';
    }

    //now add the initial problem
    //check if its a customer opened ticket or staff
    if($ticket["email_to_ticket"] == 'Yes')
    {
        //get the company(customer) information
        $sql2="SELECT * from tickets where ticketnumber = '".$ticket["ticket_seq"]."' ";
        $rs2=mysql_query($sql2,$conn);
        $ticket2=mysql_fetch_array($rs2);
        //now select the customer information
        $sql3="SELECT * from customer where sequence = '".$ticket2["company"]."' ";
        $rs3=mysql_query($sql3,$conn);
        $customer2=mysql_fetch_array($rs2);

        $name_text = $customer["company"];
    }
    else
    {
        $name_text = 'Technical Support';
    }

    //set the right date/time format
    $ticket_open_time = strtotime($ticket["datetime"]);
    $ticket_open_time = date('d F Y G:H', $ticket_open_time);

    $update_email.='<strong>'.$ticket["opened_by"].' | '.$name_text.'</strong>
    <br>
    '.$ticket_open_time.'
    <br><br>
    '.nl2br($ticket["summary"]).'
    <br><br>
    <hr />';

    $update_email.='</font>';

コードに問題はなく、エラーなどもありませんが、 $email_update; をエコーすると ticketsテーブルからの行とテーブルからの1行のみを表示するだけticket_updatesですが、データベースでSQLを直接実行すると、ticket_updatesテーブルから表示する必要がある行がさらにあります

.=while ループで on 変数を使用する際に問題はありますか? これを別の方法で行う必要がありますか?

4

1 に答える 1

2

この行を変更します。

$sql=mysql_query($sql,$conn);

これに:

$rs=mysql_query($sql,$conn);

また、次の理由により、mysql_ 拡張機能の使用を停止する必要があります。

This extension is deprecated as of PHP 5.5.0, 
and will be removed in the future. Instead, the MySQLi or PDO_MySQL 
extension should be used. See also MySQL: choosing an API guide and 
related FAQ for more information.
于 2013-10-03T12:44:51.967 に答える