php - need help returning sql sum of $variable table name -



php - need help returning sql sum of $variable table name -

i'm trying homecoming sum of balances table , can next code work when using specific table name

$qry = mysql_query("select sum(balance) total table1 "); $row = mysql_fetch_assoc($qry); echo $row['total'];

the problem i'm having table name changes , needs variable when utilize next code no result

$table="table1"; $qry = mysql_query(" select sum(balance) total $table "); $row = mysql_fetch_assoc($qry); echo $row['total'];

can offer help please?

how about:

$qry = mysql_query(" select sum(balance) total " . $table );

php mysql sql variables sum

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -