在我的SQL查询下方。
$query = mysql_query("SELECT COUNT(*) as `box.id`
from boxes as box
left join page_boxes as pbox
on box.id=pbox.bid
left join page_subcribers as pages
on pages.page_id=pbox.page_id
left join category_boxes as cbox
on box.id=cbox.bid
left join subcribers as catsb
on cbox.category_id=catsb.cid
where pages.uid='".$session_id."' or catsb.uid='".$session_id."'
and box.status='".$approval."'")or die (mysql_error());
$row = mysql_fetch_array($query);
$total = $row['id'];
我需要box.id
作为此查询的索引$total = $row['id'];
,但是当我像$total = $row['id'];
这样使用它时,我收到错误
Notice: Undefined index: id in C:xampphtdocsmediactrx.php on line 12
如何获取此索引 ID 值?
我认为这将是$total = $row['box.id'];
只需删除反引号
$query = mysql_query("SELECT COUNT(*) as box.id
或者你可以使用这样的反引号
$query = mysql_query("SELECT COUNT(*) as `box`.`id`
但不是表和列与反引号一起
`box.id` // <---this wrong