that I had the code right but I must have done something wrong ...
This is my code:
Expand|Select|Wrap|Line Numbers
- $earn = array();
- $comm = array();
- $sql = "SELECT earn, comm, FROM main WHERE id = '$Db_prod' ORDER BY mday_no DESC ";
- $result = mysql_query($sql) or die("could not execute SELECT cb_main". mysql_error());
- $num = mysql_num_rows($result);
- if ($num == 0 ) {
- $earn[] = 0;
- $comm[] = 0;
- }
- else {
- while( $row = mysql_fetch_assoc($result) ) {
- $earn[] = $row['earn'];
- $comm[] = $row['comm'];
- }
- }
I have tried this code and I am getting a problem with it:
When I display the resulting array with this:
print_r($earn);
I get:
Array ( [0] => Array ( ) [1] => 34.01 [2] => 33.36 [3] => 33.36 [4] => 82.25 [5] => 82.25 )
So I seem to have created a double array somehow
And hence max($earn); just returns "Array" rather than the
maximum value.
What am I doing wrong ?
.