I'm trying to do a select here but we're not displaying any data, is as follows, I need to do a select count on a table in postgre me where it displays how many records to select this field that are not null, just how many records nonzero. There is already a similar function however it has all the records and I'm not getting to do this to tell only the records nonzero. The codes are as follows: This is what displays for user:
<?php
require_once 'chklogado.php';
require_once 'model.php';
$funcao = $_SESSION['funcao'];
$model = new Model();
$cont = array();
$cont['promocoes'] = $model->get_count('promocoes');
$cont['promocoes_novos'] = $model->get_promonovos('promocional');
$cont['seminovos'] = $model->get_count('seminovos');
$cont['noticias'] = $model->get_count('noticias');
$cont['news'] = $model->get_count('contatos_newsletter');
$cont['banner'] = $model->get_count('banner');
$cont['pwd'] = $model->get_count('passwd');
?>
<ul>
<?php if($funcao<4 ) { // todos menos marketing?>
<li class="inovos"><a href="promocoes-novos.php" title=""><span>Promoções de Carros Novos</span></a><span class="numberMiddle"><?php echo get_value($cont, 'promocoes_novos'); ?></span></li>
<?php } //endif ?>
<?php if($funcao==1 or $funcao==3 ) { // administrador e vendas ?>
<li class="iOrders"><a href="lista-promocoes.php" title=""><span>Promoções</span></a><span class="numberMiddle"><?php echo get_value($cont, 'promocoes'); ?></span></li>
<?php } //endif ?>
<?php if($funcao==1 or $funcao==4 ) { // administrador e marketing ?>
<li class="iStat"><a href="lista-banners.php" title=""><span>Cadastro Banners</span></a><span class="numberMiddle"><?php echo get_value($cont, 'banner'); ?></span></li>
<?php } //endif ?>
<?php if($funcao<4 ) { // todos menos marketing?>
<li class="iMes"><a href="lista-seminovos.php" title=""><span>Add Seminovo</span></a><span class="numberMiddle"><?php echo get_value($cont, 'seminovos'); ?></span></li>
<?php } //endif ?>
<?php if($funcao==1 or $funcao==4 ) { // administrador e marketing ?>
<li class="inoticias"><a href="lista-noticias.php" title=""><span>Notícias</span></a><span class="numberMiddle"><?php echo get_value($cont, 'noticias'); ?></span></li>
<?php } //endif ?>
<?php if($funcao==1 or $funcao==4 ) { // administrador e marketing ?>
<li class="iNews"><a href="lista-newsletter.php" title=""><span>Mala direta</span></a><span class="numberMiddle"><?php echo get_value($cont, 'news'); ?></span></li>
<?php } //endif ?>
<?php if($funcao==1 ) { // administrador ?>
<li class="iUser"><a href="lista-usuarios.php" title=""><span>Admin Usuário</span></a><span class="numberMiddle"><?php echo get_value($cont, 'pwd'); ?></span></li>
<?php } //endif ?>
</ul>
And this is the function that does the select:
function get_count($table = ''){
return $table ? pg_fetch_result($this->get_all($table, '', 'COUNT(*) as total'), 0, 'total') : 0;
}
function get_promonovos($table = ''){
//return $result=pg_query($sql="SELECT count(venda) FROM promocional where venda>0;");
//$sql=("select * from promocional where venda is not null;");
//$resultado = pg_fetch_array($sql);
//return pg_free_result($resultado);
//$data = pg_Fetch_Object($result, 0);
//return pg_fetch_array($result, $sql);
//return pg_free_result($result);
$result = pg_query("select count(*) from promocional where venda is not null;");
$count = pg_fetch_result($result);
}
You can see that the function "get_Count" makes the account, this function "get_promonovos" is that I need to display the result of the select but testing here or he returns with a null or "Release id #". Anyone know what can be?