+-----+-----+----+----+----+----+----+----+
| Uid | Q1 | Q2 | Q3 | Q4 | Q5 | Q6 | Q7 |
+=====+=====+====+====+====+====+====+====+
| 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 |
+-----+-----+----+----+----+----+----+----+
This is a structure of my database. I want to fetch number of columns where uid = $_SESSION['Uid']
.
I want Numbers of columns where 0 is present in between Q1, Q2, Q5, Q7
something like this, (not a query its just for reference)
$Uid = $_SESSION['Uid'];
$result = mysql_query("SELECT Q1, Q2, Q5, Q7 FROM userdata WHERE Uid = '$Uid' && have 0");
echo mysql_num_fields($result);
so it will return 2 or this can be solve by using count function. Or how should I transform or create a new table like this after selecting all fields for that particular user?
+----+----+
| Q | A |
+====+====+
| Q1 | 1 |
+====+====+
| Q2 | 0 |
+====+====+
| Q3 | 1 |
+====+====+
| Q4 | 0 |
+====+====+
| Q5 | 1 |
+====+====+
| Q6 | 1 |
+====+====+
| Q7 | 0 |
+====+====+