-1

The following query is fetching some product info on a page which is fine, but I also want to show the number of the product that it occurs as a text, however, I used groupby but I also want to use count on pro_id.

 "SELECT * FROM cart  WHERE session_id='" . $_SESSION['session'] . "' GROUP BY 
    pro_id  "
the_lorem_ipsum_guy
  • 432
  • 1
  • 15
  • 26
basiclearner
  • 49
  • 1
  • 8

2 Answers2

0

Your query won't work. Try like this;

 "SELECT pro_id,count(*) FROM cart  WHERE session_id='" . $_SESSION['session'] . "' GROUP BY 
  pro_id  "
lucky
  • 12,110
  • 4
  • 20
  • 41
0

Use this query:

"SELECT pro_id,count(pro_id) FROM cart  WHERE session_id='" . $_SESSION['session'] . "' GROUP BY pro_id  "
Himanshu Upadhyay
  • 6,438
  • 1
  • 16
  • 32