-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
  • 452
  • 1
  • 12
  • 27
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,734
  • 4
  • 24
  • 46
0

Use this query:

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