Jayjay
Jayjay

Reputation: 5

Echo SUM from mysql

<?php $q = $this->db->query("select SUM(pocet_dni) as pocet from holiday where teacher_id="._get_current_user_id($this));
                                 $pocet_dni = $row['pocet'];
                                    echo $pocet;
               ?>

I can not echo SUM. What is wrong?

Upvotes: 0

Views: 66

Answers (1)

JJJJ
JJJJ

Reputation: 1358

$pocet does not exists. Use row_array().

$q = $this->db->query("select SUM(pocet_dni) as pocet from holiday where teacher_id="._get_current_user_id($this))->row_array();
$pocet = $q['pocet'];
echo $pocet;

Upvotes: 2

Related Questions