0
我的查询在db上执行时返回正确的数据,但在运行时company_title返回null。所有其他领域的工作。 $行[“COMPANY_NAME”]是代码我不能让工作:特定列的空值结果 - php/mysql
$query = "select * from invoices i, company_lookup cl, students s where i.company_id = cl.company_id and i.student_id = s.student_id;";
$results = $DB->query($query);
$invoices = mysql_query("select * from invoices");
?>
<table border="1" id="hl" name="hl">
<tr>
<th>Month/Year</th>
<th>Full Amount</th>
<th>Company</th>
</tr>
<?php while ($row = mysql_fetch_array($invoices)) {
$invoice_date = $row['invoice_date'];
?>
<tr onMouseOver="showInvoicePayments(<? echo $row['invoice_id'] ?>);this.bgColor = '#C0C0C0'" onMouseOut ="this.bgColor = '#FFFFFF'" bgcolor="#FFFFFF">
<td><? echo date('F Y',strtotime($invoice_date)) ?></td>
<td><? echo '$' . $row['full_amount'] ?></td>
<td><? echo $row['company_name'] ?></td>
</tr>
<?
}
?>
你确定,现场和你的开发机器上的数据库是相同的吗? – kirilloid 2012-03-13 16:19:19
在您使用的任何表中是否实际存在company_name字段?仅仅因为你可以在PHP数组引用(你的$行)中使用任何你想要的键,并不意味着实际上有来自MySQL的相应的字段结果。 – 2012-03-13 16:20:51
@ini因为你得到'$ invoices'行而不是'$ query'try'$ results ['company_name']' – mgraph 2012-03-13 16:21:03