PHP sum MySql table column and return message if > some #
Posted: Mon Mar 28, 2011 3:24 pm
Hi!
I'm trying to help a non-profit organize their volunteer signups. I have the information going from an html/php form into a MySQL database with no problem. The trick is that they only want to offer a shift if it hasn't been filled by a certain # of people. So I'm trying to add up the # in the column of shift1_volun in the database info_volun and if the number = less than 4 I want to return a radio box and shift time (like 'Saturday 5-7) so that they can sign up. The radio box will input a number of 1 into the column so that I can see when we're full.
Can anyone help me? I tried this (modeled after Dreamweaver recordsets- $pride_volun is my connection)
mysql_select_db($database_pride_volun, $pride_volun);
$query_rsCount = "SELECT SUM(shift1_volun) FROM info_volun";
$rsCount = mysql_query($query_rsCount, $pride_volun) or die(mysql_error());
$row_rsCount = mysql_fetch_array ($rsCount);
$totalRows_rsCount = mysql_num_rows($rsCount);
But I didn't have any success even echoing the count with php in the body. Am I off to the right start?
Any help would be sooooo appreciated!
I'm trying to help a non-profit organize their volunteer signups. I have the information going from an html/php form into a MySQL database with no problem. The trick is that they only want to offer a shift if it hasn't been filled by a certain # of people. So I'm trying to add up the # in the column of shift1_volun in the database info_volun and if the number = less than 4 I want to return a radio box and shift time (like 'Saturday 5-7) so that they can sign up. The radio box will input a number of 1 into the column so that I can see when we're full.
Can anyone help me? I tried this (modeled after Dreamweaver recordsets- $pride_volun is my connection)
mysql_select_db($database_pride_volun, $pride_volun);
$query_rsCount = "SELECT SUM(shift1_volun) FROM info_volun";
$rsCount = mysql_query($query_rsCount, $pride_volun) or die(mysql_error());
$row_rsCount = mysql_fetch_array ($rsCount);
$totalRows_rsCount = mysql_num_rows($rsCount);
But I didn't have any success even echoing the count with php in the body. Am I off to the right start?
Any help would be sooooo appreciated!