Guest User

Untitled

a guest
Dec 13th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. function votacionPresidentesWidgetM()
  2. {
  3.  
  4. header('Content-Type: application/json');
  5. $json_data = file_get_contents('listadoComunasMarquee.txt');
  6.  
  7. // separamos el fichero en lineas (n)
  8. $json_data = split( "n", $json_data );
  9.  
  10. // para cada elemento
  11. $longitudCodZonaW = count($json_data);
  12.  
  13. for ($x = 0; $x < $longitudCodZonaW; $x++)
  14. {
  15. // lo separamos por tabulador (t)
  16. $dupla = preg_split("/t/", $json_data[$x], -1, PREG_SPLIT_NO_EMPTY);
  17. // sustituimos el elemento por un array asociativo similar
  18. $json_data[$x] = array(
  19. "ID_CIUDAD" => $dupla[0]
  20. //"ID_CIUDAD" => $dupla[1]
  21. );
  22. }
  23.  
  24. $longitudCodZonaW = count($json_data);
  25. //print_r($longitudCodZonaW);
  26.  
  27. //echo($longitudCodZonaW);
  28. for($i=0; $i<=$longitudCodZonaW; $i++)
  29. {
  30.  
  31. $codZonaW = $json_data[$i]["ID_CIUDAD"];
  32. //$codZonaWM = split("n", $codZonaW);
  33.  
  34. //print_r($codZonaW);
  35.  
  36.  
  37.  
  38. // print_r($codZonaWM);
  39. $consulta = "SELECT DISTINCT
  40. CANDIDATOS.`GLOSA_CAND`,
  41. VOTACION.`VOTOS`,
  42. VOTACION.`PORCENTAJE_VOTOS`
  43. FROM VOTACION_PRESIDENTES_2017 AS VOTACION
  44. INNER JOIN ESCENARIO_CANDIDATOS_2017 AS CANDIDATOS
  45. WHERE VOTACION.`COD_ZONA`=$codZonaWM
  46. AND VOTACION.`AMBITO` = 4
  47. AND VOTACION.`COD_ELEC` =4
  48. AND CANDIDATOS.`COD_ELEC`=4
  49. AND VOTACION.`COD_AMBITO`= CANDIDATOS.`COD_CAND`
  50. ORDER BY VOTACION.`VOTOS` DESC";
  51.  
  52. $data = $this->bd->prepare($consulta);
  53.  
  54. $data->execute();
  55. $data->bind_result($dato1,$dato2,$dato3);
  56.  
  57. while ($data->fetch()){
  58. $this->response[] = array(
  59.  
  60. "PRESIDENTE_GLOSA_WIDGETM" => utf8_encode($dato1),
  61. "PRESIDENTE_GLOSA_VOTOS_WIDGETM" => utf8_encode($dato2),
  62. "PRESIDENTE_GLOSA_PORCENTAJE_WIDGETM" => utf8_encode($dato3)
  63.  
  64.  
  65. );
  66. }
  67. }
  68.  
  69. return (json_encode($this->response));
  70. $data->close();
  71.  
  72. }
  73.  
  74. <b>Fatal error</b>: Call to a member function execute() on a non-object in <b>/home2.......
Add Comment
Please, Sign In to add comment