Jump to content

kapkap

New Members
  • Posts

    3
  • Joined

  • Last visited

kapkap's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi solved with help from a friend, a little different but gives me the data I need $query = "select department, count(department) as count from new2 group by department"; if ($result = mysqli_query($con, $query)) { while ($row = mysqli_fetch_assoc($result)) { printf ("%s (%s)\n", $row['department'], $row['count']); } /* free result set */ mysqli_free_result($result); } mysqli_close($con); thank you all
  2. Thanks any advice regarding the display of this query, I have tried so many and got nothing. Thanks
  3. Hi there I am new to this forum and not much of a php expert. I hope you can assist me. My problem is as follows: I have a column consisting of several values (in this case: sceience, art, humanistics and music) I would like to use the following mysqli query in order to count the appearances of each value in this column: $query = "SELECT SUM (IF(department = 'science', 1, 0)) AS science, SUM(IF(department = 'art', 1, 0))-> AS art FROM new2" I have tried lots of ways to loop the results but couldn't get the it working. Can anyone suggest any idea? Thanks Hanan
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.