Jump to content

Toody

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Toody's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your help jc. I was able to shorten the code a bit and am looking forward to the time when I know more about php than I don't know.
  2. Thanks to all! It works, but I need a little tweaking. I am brand new to php, but it's starting to make a little sense. What I got was: There are 10,000 Undefined There are 5,000 Members There are 5,000 Non-Members I think I have to create different echo statements because what I'd like to get is: There are 5,000 Members (I would need to subtract 2 from the total number) There are 5,000 Non-Members (this would have to add 'n' and undefined as some non-members do not have 'n' in the activate column.) (total users isn't important, but would be okay and would have to add 'y', 'n' & 'undefined') And just so I understand, AS member_group assigns the "Then" and count(*) AS total_count assigns "When" in terms of the echo statement?
  3. Thanks for your help cyberRobot. I tried the code and it was not accurate. I got: There are 1 members. There are 1 non-members. There are 2 total users. Any suggestions? Also, I was able to figure out how to subtract 2. I did this: $row=$row['COUNT(activate)'] - 2 and it worked.
  4. You know. I think the solution is way above my skill level. I'm gonna have to read more and stick to bloated code for now. Something that I hope would be simple that I can't seem to get the right syntax is subtracting 2 from the members. How exactly does it go in here? // Print out result while($row = mysql_fetch_array($result)) { echo "There are ". $row['COUNT(activate)'] ." members."; echo "<br />"; } Any help is appreciated.
  5. I'm am brand new to php and just found this forum this morning. I spent five hours yesterday trying to figure out how to count values in a column, but thanks to a post here I have now figured out how. However, the way I coded it seems a bit long. The column values are Y, N and null. I want to find out how many members (Y) and how many non-members I have on my site (N, null). The code works with the results below, but is there a shorter way to code it? RESULTS: There are 5000 members. There are 20000 non-members. There are 25000 total users. CODE: $con = mysql_connect("localhost", "xxxxxxxxxx", "xxxxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxxxx") or die(mysql_error()); $result = mysql_query("SELECT activate, COUNT(activate) FROM customers WHERE activate='y'"); // Print out result while($row = mysql_fetch_array($result)) { echo "There are ". $row['COUNT(activate)'] ." members."; echo "<br />"; } mysql_close($con); $con = mysql_connect("localhost", "xxxxxxxxxx", "xxxxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxxxx") or die(mysql_error()); $result = mysql_query("SELECT activate, COUNT(activate) FROM customers WHERE activate!='y'"); // Print out result while($row = mysql_fetch_array($result)) { echo "There are ". $row['COUNT(activate)'] ." non-members."; echo "<br />"; } mysql_close($con); $con = mysql_connect("localhost", "xxxxxxxxxx", "xxxxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxxxx") or die(mysql_error()); $result = mysql_query("SELECT activate, COUNT(activate) FROM customers WHERE activate!='0'"); // Print out result while($row = mysql_fetch_array($result)) { echo "There are ". $row['COUNT(activate)'] ." total users."; echo "<br />"; } mysql_close($con);
×
×
  • 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.