Member Avatar for jacksantho

Hi,

Any body please help me out:

[B] while loop { $val=mysql_num_rows($result14); $blnk=array(); array_push($blnk,$val); } $blnkarraysum=array_sum($blnk); [/B]

Values are not at all getting add up. why ? thanks in advance

Member Avatar for cereal

You need session, otherwise the array will become empty after each loop. This should work:

<?php session_start(); while loop { $blnk = ($_SESSION['numRows'] == NULL) array() : $_SESSION['numRows']; $val=mysql_num_rows($result14); array_push($blnk,$val); if($_SESSION['numRows'] == NULL) { $_SESSION['numRows'] = $blnk; } # start session } #$blnkarraysum=array_sum($blnk); $blnkarraysum = $blnk; ?>
Member Avatar for ddymacek

this doesn't appear to have anything to do with sessions. you need to initialize $blnk array outside your loop. otherwise you are constantly overwriting what is held in $blnk every time you pass over it in the while loop.

$blnk=array(); while loop { $val=mysql_num_rows($result14); array_push($blnk,$val); } $blnkarraysum=array_sum($blnk);
Member Avatar for cereal

@ddymacek

You're right. I had just woken up, when I wrote my post, and thinking for some strange reason to a form increasing a value o_o'

Pardon for bad suggestion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.