March 3rd, 2013, 07:48 AM
Counting Values in rows
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
March 3rd, 2013, 12:26 PM
those are columns, not rows
Originally Posted by moonunit
SELECT COUNT(gjest1) +
COUNT(gjest2) AS total_guests_registered
March 3rd, 2013, 01:36 PM
That explains why I had a hard time googeling it
Originally Posted by r937
Thanks, I actually figured it out doing a similar thing to what you suggested there!