PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/resources.inc

https://bitbucket.org/rbonesource1234/no2co2
PHP | 172 lines | 115 code | 42 blank | 15 comment | 31 complexity | ce2616ae5bbc4fb2c6d988e506ee5d44 MD5 | raw file
  1. <?php
  2. class Resources {
  3. function Resources() {
  4. }
  5. /*function FetchResource($resourceid) {
  6. global $dblink;
  7. $sql = "SELECT * FROM resources Where ResourceId= " . $resourceid;
  8. $result = mysql_query($sql,$dblink);
  9. if($result && mysql_num_rows($result) > 0){
  10. while($ary = mysql_fetch_assoc($result)){
  11. $arayres = $ary;
  12. }
  13. }
  14. return $arayres;
  15. }*/
  16. function FetchResource($keywordid) {
  17. global $dblink;
  18. $sql = "SELECT * FROM resourcesinfo r1, resources r2 Where r1.KeyWordId= '".$keywordid."' AND r1.ResourceId=r2.ResourceId";
  19. $result = mysql_query($sql,$dblink);
  20. $i=0;
  21. if($result && mysql_num_rows($result) > 0){
  22. while($ary = mysql_fetch_assoc($result)){
  23. $arayres[$i] = $ary;
  24. $i++;
  25. }
  26. }
  27. return $arayres;
  28. }
  29. function SearchResource($keyword, $city, $MTextKeyword) {
  30. global $dblink;
  31. if($keyword==-1 && $city!=-1) {
  32. $sql = "SELECT * FROM resources Where City IN('".$city."', 'All India')";
  33. $result = mysql_query($sql,$dblink);
  34. $i=0;
  35. if($result && mysql_num_rows($result) > 0){
  36. while($ary = mysql_fetch_assoc($result)){
  37. $araycity[$i] = $ary;
  38. $i++;
  39. }
  40. }
  41. return $araycity;
  42. } else if($keyword!=-1 && $city==-1) {
  43. $sql = "SELECT * FROM resourcesinfo Where KeyWordId= '".$keyword."' Order by KeyWordId";
  44. $result = mysql_query($sql,$dblink);
  45. $i=0;
  46. if($result && mysql_num_rows($result) > 0){
  47. while($ary = mysql_fetch_assoc($result)){
  48. $arayres[$i] = $ary;
  49. $i++;
  50. }
  51. }
  52. for($j=0; $j<count($arayres); $j++) {
  53. $sql = "Select * from resources Where ResourceId = '" . $arayres[$j]['ResourceId'] . "' ";
  54. $result = mysql_query($sql,$dblink);
  55. if($result && mysql_num_rows($result) > 0) {
  56. while($ary = mysql_fetch_assoc($result)) {
  57. $aryresource[$j] = $ary;
  58. }
  59. }
  60. }
  61. return $aryresource;
  62. } else if($keyword!=-1 && $city!=-1) {
  63. $sql = "SELECT * from resourcesinfo r1, resources r2 Where r1.KeywordId= '".$keyword."' AND r2.ResourceId = r1.ResourceId AND r2.City IN('".$city."','All India') ";
  64. //$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."'";
  65. $result = mysql_query($sql,$dblink);
  66. $i=0;
  67. if($result && mysql_num_rows($result) > 0){
  68. while($ary = mysql_fetch_assoc($result)){
  69. $arayres[$i] = $ary;
  70. $i++;
  71. }
  72. }
  73. return $arayres;
  74. } else if($keyword==-1 && $city==-1 && $MTextKeyword!=''){
  75. $sql = "SELECT * FROM keyword k, resourcesinfo r1, resources r2 WHERE k.MTextKeyword LIKE '%".$MTextKeyword."%' And k.KeywordId=r1.KeyWordId And r1.ResourceId = r2. ResourceId";
  76. $result = mysql_query($sql,$dblink);
  77. $i=0;
  78. if($result && mysql_num_rows($result) > 0){
  79. while($ary = mysql_fetch_assoc($result)){
  80. $arayres[$i] = $ary;
  81. $i++;
  82. }
  83. } else
  84. {
  85. $sql1 = "SELECT * FROM keyword k, resourcesinfo r1, resources r2 WHERE k.KeywordText = '".$MTextKeyword."' And k.KeywordId=r1.KeyWordId And r1.ResourceId = r2. ResourceId";
  86. $result1 = mysql_query($sql1,$dblink);
  87. $i1=0;
  88. if($result1 && mysql_num_rows($result1) > 0){
  89. while($ary1 = mysql_fetch_assoc($result1)){
  90. $arayres1[$i1] = $ary1;
  91. $i1++;
  92. }
  93. $arayres=$arayres1;
  94. }
  95. }
  96. return $arayres;
  97. }
  98. }
  99. function FetchTier3res($arykeyword) {
  100. global $dblink;
  101. for($i=0; $i<count($arykeyword); $i++) {
  102. $sql = "SELECT * FROM resourcesinfo WHERE KeyWordId = '".$arykeyword[$i]['KeywordId']."' ";
  103. $rs = mysql_query($sql, $dblink);
  104. if ($rs) {
  105. $j = 0;
  106. while($ary = mysql_fetch_assoc($rs)) {
  107. $aryres[$arykeyword[$i]['KeywordId']][$j] = $ary;
  108. $j++;
  109. }
  110. }
  111. }
  112. return $aryres;
  113. }
  114. function FetchKeyword($keywordid) {
  115. global $dblink;
  116. $sql = "SELECT * FROM keyword k,topic t Where k.KeyWordId= '".$keywordid."' And k.TopicId=t.TopicId ";
  117. $result = mysql_query($sql,$dblink);
  118. $i=0;
  119. if($result && mysql_num_rows($result) > 0){
  120. while($ary = mysql_fetch_assoc($result)){
  121. $arayres = $ary;
  122. }
  123. }
  124. return $arayres;
  125. }
  126. }
  127. ?>