How to get the record total from a table

2

I need to know how many records there are inside my table and add the total found in a variable. I'm doing the following but it does not work:

   <?php
        $w_querybusca = "SELECT * FROM Elem_matr;";
        $w_queryresultado=f_class_conecta_bd($w_querybusca);

        $result = pg_num_rows($w_queryresultado);
        echo $result;        
    ?>

Should I do it in what way?

The problem is: With this example above it only shows the values inside the table. What I need is the total contained within this table!

    
asked by anonymous 26.11.2014 / 14:01

1 answer

2

The answer to my case was the lack of use of a command of the PostgreSQL itself, which would look like this:

   <?php
        $w_querybusca = "SELECT * FROM Elem_matr;";
        $w_queryresultado=f_class_conecta_bd($w_querybusca);

        $result = pg_num_rows($w_queryresultado);
        echo $result;        
    ?>
    
26.11.2014 / 14:34