i have tried to join two tables. one is category and other is subcategory. id in category table becomes the cat id in subcategory table
category
id name catimage
2 cat1 image1
subcategory
id name subcatimage catid
1 subcat1 image2 2
the code is
<?php
ob_start();
require_once('config.php');
$selectsubcategory = mysql_query("SELECT category.name, subcategory.name, category.catimage, subcategory.id, subcategory.catid FROM category INNER JOIN subcategory ON category.id=subcategory.catid ");
$posts = array();
if(mysql_num_rows($selectsubcategory))
{
while($post = mysql_fetch_assoc($selectsubcategory))
{
$posts[] = $post;
}
header('Content-type: application/json');
echo stripslashes(json_encode(array('subcategorylist'=>$posts)));
}
else
{
header('Content-type: application/json');
echo stripslashes(json_encode(array('subcategorylist'=>'No subcategory')));
}
?>
I am getting all the details but the problem is that i am not getting category.name in result. can anyone help
P.S i have used sql, will change it later right now my concern is the functionality part