php - Echoing results of a SELECT COUNT(*) query -


with website showing different products in lots of different settings ensure number of results correct want echo them php. far have tried echoing them way know , hasn't worked.

the code on page want echo on contains require function files @ top. have tried:

<?php //call count_stock() function $result_count = count_stock(); ?> <p>showing 1-9 of <?php echo $result_count['count(*)']; ?> results.</p> <p>showing 1-9 of <?php echo $result_count[0]; ?> results.</p> <p>showing 1-9 of <?php print_r($result_count[0]); ?> results.</p> 

my function execute query is:

//create function count get_stock function count_stock() {     global $conn;     //query database count data entries in stock table     $sql = 'select count(*) stock';     //use prepared statement enhance security     $statement = $conn->prepare($sql);     $statement->execute();     $result_count = $statement->fetchall();     $statement->closecursor();     return $result_count; } 

change function :

function count_stock() {         global $conn;         //query database count data entries in stock table         $sql = 'select count(*) tot stock';         //use prepared statement enhance security         $statement = $conn->prepare($sql);         $statement->execute();         $result_count = $statement->fetch();         $statement->closecursor();         return $result_count['tot'];     } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -