#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Counting Values in rows


    Hi!

    I've made a website for our wedding and let me tell you, it's been a looong time since I did any programing in PHP and mysql.

    I actually managed to make a decent HTML5 page with some php elements a mysql DB that registers all the guests who sign up and even sends a confirmation per e-mail and sms.

    Now I'm working on the back-end where we can view all the guests who has signed up, which also works just fine.

    I have now however, arrived at the point where my mySQL skills come to an abrupt stop.

    The database is called bryllup and the only table I'm using is called deltager.

    I have two rows which I want to count, these rows are called, gjest1 and gjest2

    I need to make a php script that checks if gjest1 and gjest2 IS NOT NULL (i guess) and then count and add then into one variable and then print them.. something like:

    print "So far there are $row guests registered for the big day";

    Anyone able to help us out with this?

    Cheers, will make the musses very happy

    -

    best moonunit
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,024
    Rep Power
    4210
    Originally Posted by moonunit
    I have two rows which I want to count, these rows are called, gjest1 and gjest2
    those are columns, not rows
    Code:
    SELECT COUNT(gjest1) +
           COUNT(gjest2) AS total_guests_registered
      FROM deltager
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by r937
    those are columns, not rows
    Code:
    SELECT COUNT(gjest1) +
           COUNT(gjest2) AS total_guests_registered
      FROM deltager
    That explains why I had a hard time googeling it

    Thanks, I actually figured it out doing a similar thing to what you suggested there!

IMN logo majestic logo threadwatch logo seochat tools logo