Q:

Query does not get data from table

My problem is that when I run the query in MySQL directly it works:
SELECT * FROM SubCategoryLookup  WHERE LinkedCategoryID = '4' AND OrganizationCode = 'ibm'

While using PHP, if I give any variable then it does not get records:
$OrganizationCode=$_REQUEST['OrganizationCode'];
echo($OrganizationCode);

$CategoryId=$_REQUEST['CategoryId'];
echo($CategoryId);

$query = mysql_query("SELECT *
                        FROM SubCategoryLookup
                       WHERE LinkedCategoryID = '$CategoryId'
                             AND OrganizationCode = '$OrganizationCode'");
echo($query);

$rows = array();
while($row = mysql_fetch_assoc($query))
{
    $rows[] = $row;
}
echo json_encode($rows);

When I access this using URL:
http://www.celeritas-solutions.com/pah_brd_v1/productivo/getSubCategory.php?OrganizationCode=celeritasCategoryId=3
Below is the result it does not show records
celeritasCategoryId=3Resource id #3[]

A:

You are missing a & on your URL, should be: 
http://www.celeritas-solutions.com/pah_brd_v1/productivo/getSubCategory.php?OrganizationCode=celeritas&CategoryId=3

With a closer look you have:
OrganizationCode=celeritasCategoryId=3

And it should have been:
OrganizationCode=celeritas&CategoryId=3

Which causes $CategoryId to be unset (or in other words empty) which makes your query fail and give you no result.
You should make use of isset to make sure your variables are set:
$OrganizationCode = $_GET['OrganizationCode'];
if (!isset($OrganizationCode))
    die("There is no organization code...");

$CategoryId = $_GET['CategoryId'];
if (!isset($CategoryId))
    die("There is no category id...");

As well as sanitizing it to prevent injections using mysql-real-escape-string and properly using error handlers to know if the query failed with mysql_error:
$sql = sprintf("SELECT * 
                  FROM SubCategoryLookup 
                 WHERE LinkedCategoryID='%s' AND 
                       OrganizationCode='%s'",
               mysql_real_escape_string($CategoryId),
               mysql_real_escape_string($OrganizationCode));

$query = mysql_query($sql);

// change $link to the name of your database connection variable
if (!$query)
    die('Query failed (' . mysql_errno($link) . '): ' . mysql_error($link));

There is no more support for mysql_* functions, they are officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.

And here is what you will get:
 [{
     "SubCategoryID": "8",
     "LinkedCategoryID": "3",
     "SubCategoryTitle": "Projects: Client A",
     "SubCategoryAddedDateTime": "2013-07-12 23:16:25",
     "SubCategoryAddedByUserID": "1",
     "OrganizationCode": "celeritas"
 }, {
     "SubCategoryID": "9",
     "LinkedCategoryID": "3",
     "SubCategoryTitle": "Projects: Client B",
     "SubCategoryAddedDateTime": "2013-07-12 23:16:25",
     "SubCategoryAddedByUserID": "1",
     "OrganizationCode": "celeritas"
 }, {
     "SubCategoryID": "10",
     "LinkedCategoryID": "3",
     "SubCategoryTitle": "Projects: Client C",
     "SubCategoryAddedDateTime": "2013-07-12 23:16:25",
     "SubCategoryAddedByUserID": "1",
     "OrganizationCode": "celeritas"
 }]

