Reputation: 47
below my sql query for example.
$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'];
I need box.id
as index $total = $row['id'];
from this query but when i use this like $total = $row['id'];
i am getting error
Notice: Undefined index: id in C:\xampp\htdocs\media\ctrx.php on line 12
how can i get this index id value ?
Upvotes: 2
Views: 82
Reputation: 37253
just remove backticks
$query = mysql_query("SELECT COUNT(*) as box.id
or you can use backticks like that
$query = mysql_query("SELECT COUNT(*) as `box`.`id`
but not table and column together with backticks
`box.id` // <---this wrong
Upvotes: 0