By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

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

P: 1
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
Share this Question
Share on Google+
1 Reply


100+
P: 1,059
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.