Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/09/2015, 15:27
rangermid
 
Fecha de Ingreso: octubre-2008
Mensajes: 25
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: creacion de Variables dentro de un While php con variables definidas

quedo Perfecto el codigo

Código PHP:
Ver original
  1. <?php
  2. function Conectarse()
  3. {
  4.    if (!($link=mysql_connect("localhost","usuario","password")))
  5.    {
  6.       echo "Error conectando a la base de datos.";
  7.       exit();
  8.    }
  9.    if (!mysql_select_db("dbase"))
  10.    {
  11.       echo "Error seleccionando la base de datos.";
  12.       exit();
  13.    }
  14.    return $link;
  15. }
  16. $link=Conectarse();
  17. $puntos = "";
  18. $sql="select * from lotes";
  19. $result=mysql_query($sql,$link);
  20. $libre="fill:#0080C0;stroke:black;stroke-width:0.5; opacity:0.3;";
  21. $apartado="fill:yellow;stroke:black;stroke-width:1; opacity:0.3;";
  22. $vendido="fill:red;stroke:black;stroke-width:1; opacity:0.3;";
  23. $class="Libre";
  24. $points[1]="145,258,195,249,198,264,191,269,149,275";
  25. $points[2]="142,240,163,236,192,232,195,249,145,258";
  26. $points[3]="138,222,159,218,188,214,191,231,141,240";
  27. $points[4]="135,205,156,201,185,197,188,214,138,223";
  28. $points[5]="134,205,131,191,182,182,184,193,184,196";
  29. $points[6]="132,192,129,178,180,169,182,180,182,183";
  30. $points[7]="130,179,127,165,176,156,178,167,178,170";
  31. $points[8]="127,165,124,153,175,144,177,154,177,156";
  32. $points[9]="124,153,121,141,172,132,174,142,174,144";
  33. $points[10]="121,140,118,128,169,119,171,129,171,132";
  34. $points[11]="118,128,115,115,166,107,168,117,168,120";
  35. $points[12]="115,116,107,76,167,93,166,100,167,107";
  36. $points[13]="109,76,138,52,188,87,176,88,168,95";
  37. $points[14]="185,120,197,105,191,89,221,111,191,150";
  38. $points[15]="194,159,192,152,221,112,236,123,203,168";
  39. $points[16]="203,167,237,124,251,134,218,178";
  40. $points[17]="218,178,252,134,265,145,232,188";
  41. $points[18]="233,188,266,145,282,155,248,200";
  42. $points[19]="249,200,282,156,295,166,264,210";
  43. $points[20]="264,210,296,167,311,177,278,220";
  44. $points[21]="278,220,310,177,326,188,294,231";
  45. $points[22]="293,232,326,188,341,198,309,242";
  46. $points[23]="309,243,342,199,354,208,320,251";
  47. $points[24]="320,252,354,208,367,216,334,260";
  48. $points[25]="334,261,367,216,378,225,346,269";
  49. $points[26]="345,269,378,225,390,234,356,278";
  50. $points[27]="357,277,390,233,402,242,369,285";
  51. $points[28]="369,285,402,242,416,252,392,286";
  52. $points[29]="392,286,417,252,431,263,415,285";
  53. $points[30]="522,354,506,330,511,323,513,321,558,354";
  54. $points[31]="487,353,486,321,496,332,505,330,521,353";
  55. $points[32]="468,353,467,305,472,309,487,321,487,353";
  56. $points[33]="454,354,454,300,462,301,465,304,467,353";
  57. $points[34]="440,302,454,302,454,355,441,355";
  58. $points[35]="427,302,440,302,441,355,427,355";
  59. $points[36]="414,302,427,302,427,355,414,355";
  60. $points[37]="401,302,414,302,414,355,401,355";
  61. $points[38]="389,302,401,302,401,355,389,355";
  62. $points[39]="376,301,390,301,390,355,376,355";
  63. $points[40]="358,301,377,301,377,355,358,355";
  64. $points[41]="340,301,358,301,358,355,340,355";
  65. $points[42]="321,301,340,301,340,355,321,355";
  66. $points[43]="302,301,321,301,321,355,302,355";
  67. $points[44]="284,301,302,301,302,355,284,355";
  68. $points[45]="266,300,284,300,284,355,266,355";
  69. $points[46]="247,300,266,300,266,355,247,355";
  70. $points[47]="228,300,247,300,247,355,228,355";
  71. $points[48]="209,300,228,300,228,355,210,355";
  72. $points[49]="193,300,209,300,210,355,194,355";
  73. $points[50]="180,300,194,298,193,353,198,366,179,366";
  74. $points[51]="165,305,179,301,179,355,178,366,166,365";
  75. $points[52]="151,310,165,306,165,360,165,366,152,366";
  76. ?>
  77. <style>
  78.  polygon:hover {  fill:#804040; opacity:0.5; }
  79.  circle:hover {  fill:#804040; opacity:0.5; }
  80.  polygon.Libre{
  81.  fill:#0080C0;stroke:black;stroke-width:0.5; opacity:0.3;
  82.   }
  83.  polygon.Libre:hover{ fill:#5B060F;stroke:black;stroke-width:0.5; opacity:0.3; }
  84.  rect.Libre{
  85.  fill:#0080C0;stroke:black;stroke-width:0.5; opacity:0.3;
  86.   }
  87.  rect.Libre:hover{ fill:#5B060F;stroke:black;stroke-width:0.5; opacity:0.3; }
  88.  polygon.Apartado{
  89.  fill:yellow;stroke:black;stroke-width:1; opacity:0.3;
  90.   }
  91.  polygon.Apartado:hover{ fill:#5B060F;stroke:black;stroke-width:1; opacity:0.3; }
  92.  rect.Apartado{
  93.  fill:yellow;stroke:black;stroke-width:1; opacity:0.3;
  94.   }
  95.  rect.Apartado:hover{ fill:#5B060F;stroke:black;stroke-width:1; opacity:0.3; }
  96.  polygon.Vendido{
  97.  fill:red;stroke:black;stroke-width:1; opacity:0.3;
  98.   }
  99.  polygon.Vendido:hover{ fill:#5B060F;stroke:black;stroke-width:1; opacity:0.3; }
  100.  rect.Vendido{
  101.  fill:red;stroke:black;stroke-width:1; opacity:0.3;
  102.   }
  103.  rect.Vendido:hover{ fill:#5B060F;stroke:black;stroke-width:1; opacity:0.3; }
  104.  
  105. </style>
  106. <html>
  107. <div id="mapa" style="position: absolute; left: 350px; top: 80px;z-index: 1; background-color:#FFFFFF;"><center><img src="sembrado.png" width="625" height="510" alt="" border="0"></center></div>
  108. <div id="svgmapa" style="position: absolute; left: 350px; top: 80px;z-index: 2">
  109. <svg height="800" width="600">
  110. <a xlink:href="#" xlink:title="AREAS VERDES"><polygon points="219,284,319,285,325,279,322,272,216,193,208,193,201,198" stroke="black" stroke-linejoin="round" stroke-width="2" fill="#349A4B" style="opacity:0.8;"/></a>
  111. <a xlink:href="#" xlink:title="AREA DE JUEGOS INFANTILES"><circle cx="227" cy="227" r="11" stroke="black" stroke-width="2" fill="#FF0080" style="opacity:0.6;" /></a>
  112. <a xlink:href="#" xlink:title="AREA DE GIMNASIO MIXTO"><polygon points="258,269,265,277,274,269,267,261" stroke=" black" stroke-width="2" fill="#205CCC" style="opacity:0.8;"/></a>
  113. <?php
  114. while ($row=mysql_fetch_array($result)){
  115. $puntos=$points[ $row['lote'] ];
  116. ?>
  117. <a xlink:href="#" xlink:title='Lote <?php echo $row['lote'];?> Frente: <?php echo $row['frente'];?>m Fondo: <?php echo $row['fondo'];?>m Superficie: <?php echo$row['m2'];?>m2'><polygon class='<?php echo $class;?>' id=<?php echo $row['lote'];?> points='<?php print($puntos);?>' /></a>
  118. <?php
  119. }
  120. ?>
  121.  
  122. </svg>
  123. </div>