What I want to do is count all my filled rows of specific row name I select, let me give you an example:
Its like I have a table with 6 columns; the very first column is email - and the rest column are slot1, slot2, slot3, slot4, slot5.
Now what I want to have is a function that - when I select a specific email address - it returns how many slots are filled under that email address - just like when we use this command:
$t = select * from tabnlename where email=something
mysql_fetch_array($t)
echo $t['slot1'] . $t['slot1'] and on and on ...
I want a function that counts how many slots are filled where email = mychoiceemail
.
Let me give you some more details take a look at my sql table
supemail slot1 slot2 slot3 slot4 slot5
opera@gmail.com somedata somedata somedata somedata somedata
kaku@gmail.com somedata somedata somedata
nashu@gmail.com somedata
now what i want is when i select opera@gmail.com the function should return 5 as it has all 5 columns filled ! when i select kaku@gmail.com it should return 3 as it has 3 slots filled and when i select nashu@gmail.com it should return 1 only as it has only 1 slot filled !
Have a look at mysqli_query, there are plenty of examples there.
Your query could look something like:
select Count(*)
from MyTable
where email = $something
http://php.net/manual/en/function.mysql-num-rows.php
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);
$result = mysql_query("SELECT * FROM table1 where email='stuff@email.com'", $link);
$num_rows = mysql_num_rows($result);
echo "$num_rows Rows
";
?>
if i understand good , maybe u look for something like that the sql will be yours and try this code bellow
if ($t['slot1'] == "" ) {$s1 = $t['slot1'] ;}
else {$s1notnull =$t['slot1'] ; }
if ($t['slot2'] == "" ) {$s2 = $t['slot2'] ;}
else {$s2notnull =$t['slot2'] ; }
if ($t['slot3'] == "" ) {$s3 = $t['slot3'] ;}
else {$s3notnull =$t['slot3'] ; }
if ($t['slot4'] == "" ) {$s4 = $t['slot4'] ;}
else {$s4notnull =$t['slot4'] ; }
if ($t['slot5'] == "" ) {$s5 = $t['slot5'] ;}
else {$s5notnull =$t['slot5'] ; }
$array_empty = array($s1, $s2, $s3, $s4, $s5);
$how_is_empty = count($array_empty);
hope it helps EDIT .
select email,slot1 as s1, slot2 as s2, slot3 as s3, slot4 as s4, slot5 as s5, (count(s1+s2+s3+s4+s5)) from tabnlename where email=something