Hi, I'm trying to return the sum of balances from a table and can get the following code to work when using a specific table name
$qry = mysql_query("SE LECT SUM(Balance) AS total FROM table1 ");
$row = mysql_fetch_ass oc($qry);
echo $row['total'];
The problem im having is that my table name changes and this needs to be a variable but when i use the following code I get no result
$table="table1" ;
$qry = mysql_query(" SELECT SUM(Balance) AS total FROM $table ");
$row = mysql_fetch_ass oc($qry);
echo $row['total'];
Can anyone offer some help please?
$qry = mysql_query("SE LECT SUM(Balance) AS total FROM table1 ");
$row = mysql_fetch_ass oc($qry);
echo $row['total'];
The problem im having is that my table name changes and this needs to be a variable but when i use the following code I get no result
$table="table1" ;
$qry = mysql_query(" SELECT SUM(Balance) AS total FROM $table ");
$row = mysql_fetch_ass oc($qry);
echo $row['total'];
Can anyone offer some help please?
Comment