cyberangel Posted December 30, 2007 Share Posted December 30, 2007 Hi Everybody, I am new to MySQL and PHP and am experimenting a bit. Now I got a table which is updated by a form with radio buttons. The checked values of the Radio Buttons are "Very Good, Good and Bad". The problem that I am currently having is that The Radio Buttons update multilple columns, say Column1, Column2 and Column3. Means that all the three columns contain only these 3 values repeatedly. I to make reports I can count the Value "Very Good" in a columns using the following query: ------------------------------------------------ "SELECT column1, COUNT(*) AS total FROM backup WHERE StartDate AND EndDate BETWEEN '2006-12-01' AND '2007-12-31' AND column1 = 'Very Good' GROUP BY column1"); ------------------------------------------------ Now I want to count the value "Very Good" in all 3 columns and been Googling since hours without any success. Would appreciate all the help. The second query that I use to count all the group and count the records in a column is: ------------------------------------------------- SELECT column1, COUNT(*) AS total FROM backup WHERE StartDate AND EndDate BETWEEN '2006-12-01' AND '2007-12-31' GROUP BY column1 ORDER BY total DESC ---------------------------------------------------- Now I want to group and count the records in all the 3 columns together but here too I couldn't figure out. Please Help Quote Link to comment https://forums.phpfreaks.com/topic/83729-help/ Share on other sites More sharing options...
drranch Posted December 30, 2007 Share Posted December 30, 2007 Show us your insert statement for the radio buttons Quote Link to comment https://forums.phpfreaks.com/topic/83729-help/#findComment-426067 Share on other sites More sharing options...
cyberangel Posted December 30, 2007 Author Share Posted December 30, 2007 Hi drranch, I don't really know if the code used for Radio Buttons would be of any help as they are working properly. They insert the values into the table. What I now want to do is to read(Count) from the table. Anyway below is the code used for the Radio Buttons. _________________________________________ <INPUT TYPE=radio NAME="column1" Value="Very Good"> <INPUT TYPE=radio NAME="column1" Value="Good"> <INPUT TYPE=radio NAME="column1" Value="Bad"> <INPUT TYPE=radio NAME="column2" Value="Very Good"> <INPUT TYPE=radio NAME="column2" Value="Good"> <INPUT TYPE=radio NAME="column2" Value="Bad"> <INPUT TYPE=radio NAME="column3" Value="Very Good"> <INPUT TYPE=radio NAME="column3" Value="Good"> <INPUT TYPE=radio NAME="column3" Value="Bad"> <INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT"></FORM> ____________________________________________ Now these 9 Radio Buttons will insert the 3 Values in 3 different columns. All I want to do is for example to count how many times the value "Very Good" is inserted in all 3 columns. I can count it from 1 column simply with a COUNT statement in my previouse post. I just want to find a way to count it from all three columns at the same time. Quote Link to comment https://forums.phpfreaks.com/topic/83729-help/#findComment-426080 Share on other sites More sharing options...
drranch Posted January 1, 2008 Share Posted January 1, 2008 If I understand you right you only want to know how to query and count how many times the word "very Good" is in all of the three columns... "SELECT column1, column2, columm3, COUNT(*) AS total FROM backup WHERE StartDate AND EndDate BETWEEN '2006-12-01' AND '2007-12-31' AND column1 = 'Very Good' AND column2=Very Good AND column3=Very Good GROUP BY column1")" Quote Link to comment https://forums.phpfreaks.com/topic/83729-help/#findComment-427136 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.