468,483 Members | 2,441 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,483 developers. It's quick & easy.

how can i count the filled cells/columns of a mysql row with PHP?

Kindly view the code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include("../db.php");
  3. $result = mysql_query("SELECT * FROM accounts WHERE id LIKE 7");
  4. while($r=mysql_fetch_array($result))                                {                                        $clientname=$r['name'];                                $date=$r['date'];                                    $clentid=$r['id'];
  5. $data1=$r['d1'];
  6. $data2=$r['d2'];
  7. $data3=$r['d3'];
  8. $data4=$r['d4'];
  9. $data5=$r['d5'];
  10. $data6=$r['d6'];
  11. $data7=$r['d7'];
  12. $data8=$r['d8'];
  13. $arr = array($clientname, $date, $clientid, $data1, $data2, $data3, $data4, $data5, $data6, $data7, $data8);
  14. $count = 0;
  15. foreach ($arr as $value) {
  16. $arr = strlen($value);
  17. if (strlen($value) <= 0){
  18. $count ++;
  19. }
  20. echo $count;}
  21. }
  22. ?>
  23.  
how can i get the only number of number of columns/cells that are having values in it.
only NUMBER,,,
Suppose d1, d4, d5, d8 having value in it the result gies only number "4".

Hope anyone can give me solution for this....thanks in advance...
Nov 8 '11 #1
1 2465
johny10151981
1,059 1GB
try this function mysql_num_fields
Nov 9 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by knoak | last post: by
68 posts views Thread by Martin Joergensen | last post: by
5 posts views Thread by apking | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.