Hello everyone,
I was wondering, is there an easier way to write what i have below? I have a seperate SELECT for each column v1,v2,v3, etc. This is fine for a few, but if i expand and have about 20 or so, it could get cumbersome. I'm sure there is a better way to get the same results, I just don't know what it is...
Thanks in advance for any help!
////Get V1 Values//////////////////////////
$sql = "SELECT count(value)
FROM $table_name
WHERE value = \"V1\"
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
$v1_total = mysql_result($result,0,"count(value)");
$v1_percent = substr($v1_total/$total*100,0,4);
////Get V2 Values//////////////////////////
$sql = "SELECT count(value)
FROM $table_name
WHERE value = \"V2\"
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
$v2_total = mysql_result($result,0,"count(value)");
$v2_percent = substr($v2_total/$total*100,0,4);
////Get V3 Values//////////////////////////
$sql = "SELECT count(value)
FROM $table_name
WHERE value = \"V3\"
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
$v3_total = mysql_result($result,0,"count(value)");
$v3_percent = substr($v3_total/$total*100,0,4);