Count Values with PHP and SQL

3

Well, good afternoon.

I have the following question. I have a questionnaire with 10 questions, the answers to these questions can be from 0 to 5, I would like to make a while leaving counting the answers.

I thought of the following way and go concatenating as the loop was being repeated.

$inicio = 1;

while($inicio <= 10){

$query = "&#36query$inicio";
$row = "&#36row$inicio";



$query = mysql_query("SELECT * FROM carrefour WHERE notapergunta1=1 AND statusPesquisa=2");
$row  = mysql_num_rows($query);





$inicio++;
}
    
asked by anonymous 22.07.2015 / 22:42

1 answer

3

I do not understand much of PHP, but you can put it with the following SQL implementations:

SELECT count(*) FROM nometabela WHERE Resposta = "1";

With this code you can echo your PHP and find out how many answers!

    
22.07.2015 / 23:19