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
Post a Comment