我正在创建一个循环记录的函数,我想返回项目数组
if(!function_exists("TicketAttachments")) {
function TicketAttachments($update_sequence) {
global $conn, $pdo_conn;
$results = array();
$sql="SELECT * from ticket_updates where ticketnumber = '".$update_sequence."' and type = 'attachment' ";
$rs=mysql_query($sql,$conn);
while($result=mysql_fetch_array($rs)) {
$results["link"] = 'media/ticket_attachments/'.$result["notes"];
$results["name"] = $result["notes"];
}
return $results;
}
}
我在这里叫它:
$attachments = TicketAttachments($TicketUpdate["sequence"]);
foreach($attachments as $att) {
echo $att["name"];
}
但这与h5
相呼应,而name = 55388-20150929124302-screen dump 28092015.docx
答案 0 :(得分:4)
我认为你需要结合数组
if(!function_exists("TicketAttachments")) {
function TicketAttachments($update_sequence) {
global $conn, $pdo_conn;
$results = array();
$sql="SELECT * from ticket_updates where ticketnumber = '".$update_sequence."' and type = 'attachment' ";
$rs=mysql_query($sql,$conn);
while($result=mysql_fetch_array($rs)) {
$results[] = array(
"link"=>'media/ticket_attachments/'.$result["notes"],
"name" => $result["notes"];
);
}
return $results;
}
}