Populating a certain value from a field in an SQL DB

Posted on 2003-03-09
Medium Priority
Last Modified: 2006-11-17
I have a MYSQL database running with a single table named 'users'.  In that table I have a field called 'account_status' which can have one of 4 values (0, 1, 2, 5).  Anyhow, what I want to do I call a php script to loop through the whole database and return the number of rows (or users) that contain a value of say, 2.  Then I would print it to my page saying 'There are 'THIS MANY' users awaiting activation".  Really simple question, but I would appreciate a quick answer. Thanks!
Question by:triden
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

carchitect earned 200 total points
ID: 8097250
$sql="select * from users where account_status=2";
echo "No. of usres $rowcnt";

Author Comment

ID: 8099096
Hmm, I get an error:

Warning: Supplied argument is not a valid MySQL result resource in /usr/www/cybermart/admin/main.php on line 13

This is what I have written:

$sql = mysql_query("SELECT * FROM users WHERE account_status='1'");
$result = mysql_query($sql);
$num_activation = mysql_num_rows($result);  //LINE 13

I already have the connection started in an include file.

Author Comment

ID: 8099120
Sorry about that last error, i figured it out. thanks!

Expert Comment

ID: 8104284
thx triden for accpting my answer

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question