File: /home/barbeatleanalyti/www/api.beatleanalytics.com/live/getPagesContent.php
<?php
/*
* Following code will list all the products
*/
// array for JSON response
$response = array();
// include db connect class
require_once 'db_connect.php';
// connecting to db
$db = new DB_CONNECT();
if (isset($_GET["indLoginId"])) {
$indLoginId = $_GET['indLoginId'];
// get all products from products table
$result = mysql_query("SET NAMES utf8"); //the main trick form hindi languages
$result = mysql_query("SELECT * FROM beatle_industry where db_IndLoginId = '$indLoginId'") or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// products node
$response["beatle_industry"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$deptDetail = array();
$deptDetail["indId"] = $row["IndId"];
$deptDetail["indName"] = $row["db_industry"];
$deptDetail["indLoginId"] = $row["db_IndLoginId"];
$deptDetail["pagesId"] = $row["db_pagesId"];
$deptDetail["keywordName"] = $row["keywordName"];
$deptDetail["indTypeId"] = $row["db_ind_type_id"];
// foreach ($row['db_pagesId'] as $IndKey => $IndVal)
// {
$rsPages_ = explode(',',$row["db_pagesId"]);
/*print_r($rsPages_);die;
$str = implode("','",$rsPages_);
$str = "('".$str."')";*/
//}
$deptDetail["pages"] = array();
for($i = 0; $i < count($rsPages_); $i++){
//echo $rsPages_[$i];
$rsPages = mysql_query("SELECT * FROM beatle_page where pageId = ".$rsPages_[$i]." ") or die(mysql_error());
$rowp = mysql_fetch_array($rsPages);
//while ($rowp = mysql_fetch_array($rsPages)) {
//echo $result['pageId'];
$pageDetails = array();
$pageDetails["pid"] = $rowp["pageId"];
$pageDetails["pagename"] = $rowp["db_pagename"];
$pageDetails["pagetype"] = $rowp["db_pagetype"];
$rsPageContent = mysql_query("SELECT * FROM beatle_pagecontent where db_pageid LIKE ".$rowp["pageId"]." order by pageConId asc") or die(mysql_error());
$pageDetails["pageContent"] = array();
while ($rowpc = mysql_fetch_array($rsPageContent)) {
$pageContentDetails = array();
$pageContentDetails["pageConId"] = $rowpc["pageConId"];
$pageContentDetails["pageConTitle"] = $rowpc["db_pageConTitle"];
$pageContentDetails["pageselection"] = $rowpc["db_pageselection"];
$pageContentDetails["pageChoice"] = $rowpc["db_pageChoice"];
$rsPagesChoice = explode(",",$rowpc['db_pageChoice']);
$rateNo = 5;
$pageContentDetails["pageRatings"] = array();
for($j = 0; $j < count($rsPagesChoice); $j++){
$pageRatings = array();
$pageRatings["param"] = $rsPagesChoice[$j];
$pageRatings["rate"] = $rateNo;
$rateNo--;
array_push($pageContentDetails["pageRatings"], $pageRatings);
}
array_push($pageDetails["pageContent"], $pageContentDetails);
}
array_push($deptDetail["pages"], $pageDetails);
// }
}
//$rsPages = mysql_query("SELECT * FROM beatle_page where pageId ".$rsPages_." order by pageId") or die(mysql_error());
/* $deptDetail["pages"] = array();
while ($rowp = mysql_fetch_array($rsPages)) {
$pageDetails = array();
$pageDetails["pid"] = $rowp["pageId"];
$pageDetails["pagename"] = $rowp["db_pagename"];
$pageDetails["pagetype"] = $rowp["db_pagetype"];
$rsPageContent = mysql_query("SELECT * FROM beatle_pagecontent where db_pageid LIKE ".$rowp["pageId"]." ") or die(mysql_error());
$pageDetails["pageContent"] = array();
while ($rowpc = mysql_fetch_array($rsPageContent)) {
$pageContentDetails = array();
$pageContentDetails["pageConId"] = $rowpc["pageConId"];
$pageContentDetails["pageConTitle"] = $rowpc["db_pageConTitle"];
$pageContentDetails["pageselection"] = $rowpc["db_pageselection"];
$pageContentDetails["pageChoice"] = $rowpc["db_pageChoice"];
$rsPagesChoice = explode(",",$rowpc['db_pageChoice']);
$rateNo = 4;
$pageContentDetails["pageRatings"] = array();
for($i = 0; $i < count($rsPagesChoice); $i++){
$pageRatings = array();
$pageRatings["param"] = $rsPagesChoice[$i];
$pageRatings["rate"] = $rateNo;
$rateNo--;
array_push($pageContentDetails["pageRatings"], $pageRatings);
}
array_push($pageDetails["pageContent"], $pageContentDetails);
}
array_push($deptDetail["pages"], $pageDetails);
}*/
array_push($response["beatle_industry"], $deptDetail);
}
// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
} else {
// no products found
$response["success"] = 0;
$response["message"] = "No deptId found";
// echo no users JSON
echo json_encode($response);
}
}else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>