繼承人我的代碼:從一個表中選擇,從另算其中id的鏈接
$sql = mysql_query("select c.name, c.address, c.postcode, c.dob, c.mobile, c.email,
count(select * from bookings where b.id_customer = c.id) as purchased, count(select * from bookings where b.the_date > $now) as remaining,
from customers as c, bookings as b
where b.id_customer = c.id
order by c.name asc");
你可以看到什麼,我試圖做的,但林不知道如何正確地寫這個查詢。
繼承人的錯誤我得到:
警告:mysql_fetch_assoc():提供 參數是不是一個有效的MySQL結果 資源
繼承人我mysql_fetch_assoc:
<?php
while ($row = mysql_fetch_assoc($sql))
{
?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['mobile']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['purchased']; ?></td>
<td><?php echo $row['remaining']; ?></td>
</tr>
<?php
}
?>
從phpmyadmin或CLI界面執行時,這是否工作? – 2011-05-11 22:07:01
請說明你如何做了你的'mysql_fetch_assoc()'查詢。 – stealthyninja 2011-05-11 22:07:23
我將它添加到原帖... – scarhand 2011-05-11 22:09:13