我试图将查询结果显示到网络表,但我得到unidentified index (column name)
。
我的代码:
$results = 0;
$resultset=odbc_exec($conn, "SELECT qem_message.createdate as Tanggal, qem_message.agent_key, qem_message.trackingnumber, qem_message.subject, qem_message.currentstatus, qem_messagestatlog.createdate as Last from qem_message, qem_messagestatlog where qem_message.currentmsglog_key = qem_messagestatlog.pkey and qem_message.createdate between '$tgl1' and '$tgl2' order by qem_message.createdate desc ");
echo "<p align='center'><table border='1' cellpadding='2'></p>";
echo "<tr> <th>Tanggal</th> <th>Agent</th> <th>Tracking Number</th> <th>Subject</th> <th>createdate</th></tr>";
while($row = odbc_fetch_array($resultset)) {
$results += 1;
if($i%2 == 1) $color = $color1;
else $color = $color2;
echo "<tr style='background-color: $color'>";
echo "<td>" . $row['createdate'] . "</td>";
echo "<td>" . $row['agent_key'] . "</td>";
echo "<td>" . $row['trackingnumber'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td>" . $row['createdate'] . "</td>";
echo "</tr>";
$i++;
}
echo "</table>";
odbc_close($conn);
&#13;
另外,我想在第3列trackingnumber
添加超链接。
请帮我纠正代码。我正在使用php 5.4
和mssql server 2005
。
答案 0 :(得分:0)
现在可以使用
$resultset=odbc_exec($conn, "SELECT qem_message.createdate as Tanggal, qem_message.agent_key, qem_message.trackingnumber, substring(qem_message.messagebody, PATINDEX('%LANGUAGE%', qem_message.messagebody)-11,10) as ID , qem_message.subject, qem_message.currentstatus, qem_messagestatlog.createdate as Last from qem_message, qem_messagestatlog where qem_message.currentmsglog_key = qem_messagestatlog.pkey and qem_message.createdate between '$tgl1' and '$tgl2' order by qem_message.createdate desc ");
echo "<p align='center'><table border='1' cellpadding='2'></p>";
echo "<tr> <th>Tanggal</th> <th>Agent</th> <th>Tracking Number</th> <th>id</th> <th>Subject</th> <th>Last Update</th></tr>";
while(odbc_fetch_array($resultset)) {
//$results += 1;
if($i%2 == 1) $color = $color1;
else $color = $color2;
echo "<tr style='background-color: $color'>";
echo "<td>" . odbc_result($resultset, "Tanggal") . "</td>";
echo "<td>" . odbc_result($resultset, "agent_key") . "</td>";
echo "<td>" . "<a href='email_trace_pop.php?trackingnumber=" . odbc_result($resultset, "trackingnumber") ."' target=\"popup\" onclick=\"window.open('email_trace_pop.php?trackingnumber=" . odbc_result($resultset, "trackingnumber") ."','name','width=400,height=400',)\" >" . odbc_result($resultset, "trackingnumber") . "</a></td>";
echo "<td>" . odbc_result($resultset, "id") . "</td>";
echo "<td>" . odbc_result($resultset, "subject") . "</td>";
echo "<td>" . odbc_result($resultset, "Last") . "</td>";
echo "</tr>";
$i++;
}
echo "</table>";
odbc_close($conn);