Satyam Gupta Satyam Gupta - 1 year ago 53
PHP Question

Join query error unknown index

Where i am wrong on this query result can someone help me.


include 'dbconfig.php';
$sql = 'SELECT SUM(total_fund.total_funds), total_fund .name from total_fund join project
WHERE total_fund.funds_id = project.project_id AND project_id=1200 GROUP BY project.project_id';
$retval = mysqli_query($dbconfig, $sql);

while ($data = mysqli_fetch_array($retval)) {

echo $data['total_funds'] . '</br>';
echo $data['name'];

Answer Source

There's a typo in your query:

total_fund .name

should be written as:

and you probably need an AS alias, anyway it's better to write your query this way:

  SUM(total_fund.total_funds) as total_funds
  total_fund join project on total_fund.funds_id = project.project_id
group by