I have two table,i want fetch two table values,this code should working fine but count=2 means loop running 2 times,return the output of 2 times,like count=3 means loop running in 3 times return output 3 times,what i did mistake....
OUTPUT
{
"status":"success",
"count":2,
"data":[
{
"id":"1",
"t_id":"STV1",
"t_title":"Horoscope Uploading",
"t_project":"1",
"t_sub_project":"Sub-project",
"t_desc":"cfdgdgdcf",
"t_priority":"Urgent",
"t_assign_to":"AE098",
"t_assign_on":"2016-04-13 12:03:49",
"t_started_on":"2016-04-14 05:30 PM",
"t_due_on":"2016-04-22 05:30 PM",
"t_complete_percentage":"100",
"t_est_hours":"35",
"t_worked":"10 Hours",
"t_comment":"dfhfghfgfsfhfgh",
"t_created_on":"2016-04-13 12:03:49",
"t_edited_on":"2016-04-14 07:01:06",
"t_status":"3",
"t_delete_on":"0"
}
]
}{
"status":"success",
"count":2,
"data":[
{
"id":"1",
"t_id":"STV1",
"t_title":"Horoscope Uploading",
"t_project":"1",
"t_sub_project":"Sub-project",
"t_desc":"cfdgdgdcf",
"t_priority":"Urgent",
"t_assign_to":"AE098",
"t_assign_on":"2016-04-13 12:03:49",
"t_started_on":"2016-04-14 05:30 PM",
"t_due_on":"2016-04-22 05:30 PM",
"t_complete_percentage":"100",
"t_est_hours":"35",
"t_worked":"10 Hours",
"t_comment":"dfhfghfgfsfhfgh",
"t_created_on":"2016-04-13 12:03:49",
"t_edited_on":"2016-04-14 07:01:06",
"t_status":"3",
"t_delete_on":"0"
}
]
}
Same ans but i will come two times,how to fix this problem
<?php
session_start();
include('dbconfig.php');
if(empty($_SESSION['email'])){
header('Location:login.php');
}
$dapartment = $_POST['department'];
$sql = mysql_query("SELECT * FROM task_employee WHERE emp_designation='$dapartment'");
$count=mysql_num_rows($sql);
$return = array();
while($r=mysql_fetch_assoc($sql)){
$emp_id=$r['emp_id'];
if($count > 0){
$mysql = mysql_query("SELECT * FROM task WHERE t_assign_to='$emp_id'");
while($row= mysql_fetch_assoc($mysql)){
$data[] = $row;
}
$return=array('status'=>'success','count'=>$count,'data'=>$data);
echo json_encode($return);
}else{
$return=array('status'=>'not found','count'=>$count,'data'=>$data);
echo json_encode($return);
}
}
?>
</div>