I want to create a summary report from two tables. one table project_typeanotherffw
Table ffw:
|-----------------------------------------------------------------------|
| ffw_id | division_id | district_id | project_type_id | name
|-----------------------------------------------------------------------|
| 1 | 30 | 1 | 2 |myAddress
|-----------------------------------------------------------------------|
| 2 | 12 | 2 | 1 | Asdfads |
|-----------------------------------------------------------------------|
| 3 | 30 | 6 | 1 | kkkkk |
|-----------------------------------------------------------------------|
| .. | .. | .. | .. | ..... |
|-----------------------------------------------------------------------|
Table project_type:
|--------------------------------
| project_type_id | project_type |
|--------------------------------|
| 1 | food |
|--------------------------------|
| 2 | work |
|--------------------------------|
| 3 | visit |
|--------------------------------|
| .. | .. |
|--------------------------------|
My desired result from two tables after applying the condition division_idwill be
|-------------------------------------------|
| no | project_type | count |
|-------------------------------------------|
| 1 | food | 2 |
|-------------------------------------------|
| 2 | work | 1 |
|-------------------------------------------|
| 3 | visit | . |
|-------------------------------------------|
| .. | .. | .. |
|-------------------------------------------|
I am trying to use this code, but it displays a repeating value during a loop
$qry = "
SELECT * FROM `project_type`
LEFT JOIN `ffw`
ON project_type.project_type_id = ffw.project_type_id
WHERE 1
";
if (strlen($_POST["division_id"]) > 0 && $_POST["division_id"] != "0")
{
$qry .= " AND division_id = '".$_POST["division_id"]."'";
}
$query = mysql_query($qry);
source
share