/lib/resources.inc
PHP | 172 lines | 115 code | 42 blank | 15 comment | 31 complexity | ce2616ae5bbc4fb2c6d988e506ee5d44 MD5 | raw file
- <?php
- class Resources {
-
- function Resources() {
- }
-
- /*function FetchResource($resourceid) {
- global $dblink;
- $sql = "SELECT * FROM resources Where ResourceId= " . $resourceid;
- $result = mysql_query($sql,$dblink);
-
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $arayres = $ary;
-
- }
- }
-
- return $arayres;
- }*/
-
-
- function FetchResource($keywordid) {
- global $dblink;
- $sql = "SELECT * FROM resourcesinfo r1, resources r2 Where r1.KeyWordId= '".$keywordid."' AND r1.ResourceId=r2.ResourceId";
- $result = mysql_query($sql,$dblink);
- $i=0;
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $arayres[$i] = $ary;
- $i++;
-
- }
- }
-
- return $arayres;
- }
-
- function SearchResource($keyword, $city, $MTextKeyword) {
- global $dblink;
-
- if($keyword==-1 && $city!=-1) {
- $sql = "SELECT * FROM resources Where City IN('".$city."', 'All India')";
- $result = mysql_query($sql,$dblink);
-
- $i=0;
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $araycity[$i] = $ary;
- $i++;
- }
- }
-
- return $araycity;
-
- } else if($keyword!=-1 && $city==-1) {
- $sql = "SELECT * FROM resourcesinfo Where KeyWordId= '".$keyword."' Order by KeyWordId";
- $result = mysql_query($sql,$dblink);
- $i=0;
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $arayres[$i] = $ary;
- $i++;
- }
- }
-
-
- for($j=0; $j<count($arayres); $j++) {
-
- $sql = "Select * from resources Where ResourceId = '" . $arayres[$j]['ResourceId'] . "' ";
- $result = mysql_query($sql,$dblink);
-
- if($result && mysql_num_rows($result) > 0) {
- while($ary = mysql_fetch_assoc($result)) {
- $aryresource[$j] = $ary;
-
- }
- }
-
- }
- return $aryresource;
-
- } else if($keyword!=-1 && $city!=-1) {
- $sql = "SELECT * from resourcesinfo r1, resources r2 Where r1.KeywordId= '".$keyword."' AND r2.ResourceId = r1.ResourceId AND r2.City IN('".$city."','All India') ";
-
-
- //$sql = "SELECT * FROM resources r1, resourcesinfo r2, keyword r3 where r1.ResourceId = r2.ResourceId And r2.KeyWordId = '".$keyword."' And r1.City='".$city."' And r3.MTextKeyword like '".$MTextKeyword."'";
-
- $result = mysql_query($sql,$dblink);
-
- $i=0;
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $arayres[$i] = $ary;
- $i++;
- }
- }
-
- return $arayres;
- } else if($keyword==-1 && $city==-1 && $MTextKeyword!=''){
-
-
- $sql = "SELECT * FROM keyword k, resourcesinfo r1, resources r2 WHERE k.MTextKeyword LIKE '%".$MTextKeyword."%' And k.KeywordId=r1.KeyWordId And r1.ResourceId = r2. ResourceId";
- $result = mysql_query($sql,$dblink);
- $i=0;
-
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $arayres[$i] = $ary;
- $i++;
- }
- } else
- {
-
-
- $sql1 = "SELECT * FROM keyword k, resourcesinfo r1, resources r2 WHERE k.KeywordText = '".$MTextKeyword."' And k.KeywordId=r1.KeyWordId And r1.ResourceId = r2. ResourceId";
- $result1 = mysql_query($sql1,$dblink);
- $i1=0;
-
- if($result1 && mysql_num_rows($result1) > 0){
- while($ary1 = mysql_fetch_assoc($result1)){
- $arayres1[$i1] = $ary1;
- $i1++;
- }
- $arayres=$arayres1;
-
-
- }
- }
- return $arayres;
-
- }
- }
-
-
- function FetchTier3res($arykeyword) {
- global $dblink;
-
- for($i=0; $i<count($arykeyword); $i++) {
- $sql = "SELECT * FROM resourcesinfo WHERE KeyWordId = '".$arykeyword[$i]['KeywordId']."' ";
- $rs = mysql_query($sql, $dblink);
-
- if ($rs) {
- $j = 0;
- while($ary = mysql_fetch_assoc($rs)) {
- $aryres[$arykeyword[$i]['KeywordId']][$j] = $ary;
- $j++;
- }
- }
- }
-
- return $aryres;
- }
-
-
-
- function FetchKeyword($keywordid) {
- global $dblink;
- $sql = "SELECT * FROM keyword k,topic t Where k.KeyWordId= '".$keywordid."' And k.TopicId=t.TopicId ";
- $result = mysql_query($sql,$dblink);
- $i=0;
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $arayres = $ary;
-
- }
- }
-
- return $arayres;
- }
- }
- ?>