How to retrieve statistical SQL results with PHP? -


after hours of trying , searching net, i'm giving , asking help. how retrieve statistical sql results php? created test table 5 entries, numeric values. phpmyadmin can several statistical computations, php cannot sum.

in sql language extremely simple:

select sum(`arbeidspercentage`) `enq_vs`; 

i put in php file function, this:

<?php   require "connect.php";   $kwearie_1 = mysqli_query($con,"select * `enq_vs`");   $x = "arbeidspercentage";   $y = "verzoeken_alg_toegek";   while($row = mysqli_fetch_array($kwearie_1))     {     echo $row[$x] . " " . $row[$y] . '<br>';     };    $kwearie_2 = mysqli_query($con,"select sum(`arbeidspercentage`) `enq_vs`");   $kwearie_2_readable = mysqli_fetch_all($kwearie_2);   echo $kwearie_2_readable;   mysqli_close($con); ?> 

but i'm getting results of first kwearie. second 1 gives either nothing, word 'array', or error report matters cannot converted string. i've tried sub functions, 'fetch_all' 'fetch_row'.

how done? tutorial do, too.

i think aliases fit here:

select sum(`arbeidspercentage)` 'sum_arbeid' ... ... echo $row['sum_arbeid']; 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -