hi i have 3 tables in mysql i retrieved the data in xml using php now i want to retrieved the same data in json format but i have some problem in queries.
i retrieved data from one table in json but unable to retrieved from three tables any help would be appreciated my code for one table is.
NOTE: i dont want to retrieve data at once i.e using join query
but want to retrieve the relevant records of particular id cause my tables are relate to other with foreign key.
e.g the id 1 in table 1 have 5 relevant records in table2 and three records in table3 what i want to do is print the id 1 record of table1 than iterate in table2 and print all the relevant records than iterate in table3 and print the relevant records and so on for id 2 of table1.
i retrieved data from one table in json but unable to retrieved from three tables any help would be appreciated my code for one table is.
Code:
$table_first = 'abc';
$query = "SELECT * FROM $table_first";
$resouter = mysql_query($query, $conn);
$set = array();
$total_records = mysql_numrows($resouter);
if($total_records >= 1){
while ($link = mysql_fetch_array($resouter, MYSQL_ASSOC)){
$set[] = $link;
}
}
echo json_encode($set);
but want to retrieve the relevant records of particular id cause my tables are relate to other with foreign key.
e.g the id 1 in table 1 have 5 relevant records in table2 and three records in table3 what i want to do is print the id 1 record of table1 than iterate in table2 and print all the relevant records than iterate in table3 and print the relevant records and so on for id 2 of table1.
Comment