我正在运行代码,设置一个名为$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
表中的行和ticket_updates
表中的一行,但如果我直接在数据库中运行SQL,则应该从ticket_updates
显示更多行表
在while循环中对变量使用.=
是否有问题?我应该这样做吗?
答案 0 :(得分:2)
更改此行:
$sql=mysql_query($sql,$conn);
到此:
$rs=mysql_query($sql,$conn);
你应该停止使用mysql_ extension,因为:
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.