继承人我的代码:从一个表中选择,从另算其中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