hi;
i have two tables in MySQL with:
1. TABLE(stat) column(c_id, FOREIGN KEY) referencing
2. TABLE (complaint) column (id_complaint, PRIMARY KEY).
TABLE (complaint) also contain a second column (complaint_type).
How can i get PHP to echo second column (complaint type) in TABLE (complaint) when it is referencing the PRIMARY KEY of this table instead(id_complaint). as regards the below mysql query:
[PHP]$sum= ("SELECT c_id, SUM(number) FROM stat
WHERE '$_POST[m_id]' = m_id AND '$_POST[l_id]' = l_id AND '$_POST[y_id]' = y_id
GROUP BY c_id") or die (mysql_error());
$sum_1 = mysql_query($sum) or die (mysql_error());
while ($sum_2 = mysql_fetch_array($sum_1)) {echo "<b>Total:</b>"; echo $sum_2 ['c_id']; echo " "; echo $sum_2['SUM(number)']; echo "<br>";}
[/PHP]
the area of concern which echoes the PRIMARY KEY is:
[PHP]echo $sum_2['c_id'];[/PHP]
and if i use:
[PHP]echo $sum_2['complaint_type'];[/PHP]it states that column does not exist which is understandable becos am selecting stat table in my query not complaint.
expecting any response. thanks