Ver Mensaje Individual
  #6 (permalink)  
Antiguo 28/11/2010, 12:01
mysterio069
 
Fecha de Ingreso: abril-2010
Mensajes: 62
Antigüedad: 14 años, 1 mes
Puntos: 0
Respuesta: alguien me puede explicar el funcionamiento de este script??

creo que lo entendi bien, he probado con esto, pero no funciona:
Código PHP:
Ver original
  1. <?
  2. include("conexion_mysql.inc");
  3.  
  4. $conexion=mysql_connect($mysql_server,$mysql_login,$mysql_pass) or die ("Error en la conexion");
  5.  
  6. mysql_select_db("calendario",$conexion);
  7.  
  8. $diames = date(j);
  9.  
  10. $numeromes=date(n);
  11.  
  12. $sql="SELECT * FROM calendario where mes=".$numeromes;
  13.  
  14. $consulta=mysql_query($sql,$conexion);
  15.  
  16.  
  17. while($fila=mysql_fetch_row ($consulta)){
  18. echo( "linkdays.addlink(".$fila[2].",".$fila[1].", 'www.tudominio.com/tuscript.php');' );
  19. }
  20. ?>
Dejandolo asi:

Código Javascript:
Ver original
  1. <script LANGUAGE="JavaScript">
  2.  
  3. <!-- Begin
  4. monthnames = new Array(
  5. "Enero",
  6. "Febrero",
  7. "Marzo",
  8. "Abril",
  9. "Mayo",
  10. "Junio",
  11. "Julio",
  12. "Agosto",
  13. "Septiembre",
  14. "Octubre",
  15. "Noviembre",
  16. "Diciembre");
  17. var linkcount=0;
  18. function addlink(month, day, href) {
  19. var entry = new Array(3);
  20. entry[0] = month;
  21. entry[1] = day;
  22. entry[2] = href;
  23. this[linkcount++] = entry;
  24. }
  25. Array.prototype.addlink = addlink;
  26. linkdays = new Array();
  27. monthdays = new Array(12);
  28. monthdays[0]=31;
  29. monthdays[1]=28;
  30. monthdays[2]=31;
  31. monthdays[3]=30;
  32. monthdays[4]=31;
  33. monthdays[5]=30;
  34. monthdays[6]=31;
  35. monthdays[7]=31;
  36. monthdays[8]=30;
  37. monthdays[9]=31;
  38. monthdays[10]=30;
  39. monthdays[11]=31;
  40. todayDate=new Date();
  41. thisday=todayDate.getDay();
  42. thismonth=todayDate.getMonth();
  43. thisdate=todayDate.getDate();
  44. thisyear=todayDate.getYear();
  45. thisyear = thisyear &#37; 100;
  46. thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
  47. if (((thisyear % 4 == 0)
  48. && !(thisyear % 100 == 0))
  49. ||(thisyear % 400 == 0)) monthdays[1]++;
  50. startspaces=thisdate;
  51. while (startspaces > 7) startspaces-=7;
  52. startspaces = thisday - startspaces + 0;
  53. if (startspaces < 0) startspaces+=7;
  54. <?
  55. include("conexion_mysql.inc");
  56.  
  57. $conexion=mysql_connect($mysql_server,$mysql_login,$mysql_pass) or die ("Error en la conexion");
  58.  
  59. mysql_select_db("calendario",$conexion);
  60.  
  61. $diames = date(j);
  62.  
  63. $numeromes=date(n);
  64.  
  65. $sql="SELECT * FROM calendario where mes=".$numeromes;
  66.  
  67. $consulta=mysql_query($sql,$conexion);
  68.  
  69.  
  70. while($fila=mysql_fetch_row ($consulta)){
  71. echo( "linkdays.addlink(".$fila[2].",".$fila[1].", 'www.tudominio.com/tuscript.php');' );
  72. }
  73.  
  74. ?>
  75. document.write('<table id="calendar" cellspacing="0" cellpadding="0" ');
  76. document.write("<caption><a href='#' title='previous month' class='nav'>&laquo;</a> "
  77. + monthnames[thismonth] + " " + thisyear
  78. + " <a href='#' title='siguiente mes' class='nav'>&raquo;</a></caption>");
  79. document.write("<tr>");
  80. document.write("<th scope='col'>Lu</th>");
  81. document.write("<th scope='col'>Ma</th>");
  82. document.write("<th scope='col'>Mi</th>");
  83. document.write("<th scope='col'>Ju</th>");
  84. document.write("<th scope='col'>Vi</th>");
  85. document.write("<th scope='col'>Sa</th>");
  86. document.write("<th scope='col'>Do</th>");
  87. document.write("</tr>");
  88. document.write("<tr>");
  89. for (s=0;s<startspaces;s++) {
  90. document.write("<td> </td>");
  91. }
  92. count=1;
  93. while (count <= monthdays[thismonth]) {
  94. for (b = startspaces;b<7;b++) {
  95. linktrue=false;
  96. document.write("<td");
  97. for (c=0;c<linkdays.length;c++) {
  98. if (linkdays[c] != null) {
  99. if ((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count)) {
  100. document.write("><a href=\"" + linkdays[c][2] + "\">");
  101. linktrue=true;
  102.       }
  103.    }
  104. }
  105. if (count==thisdate) {
  106. document.write(" class='today'>" + count);
  107. }
  108. else{
  109. if (count <= monthdays[thismonth]) {
  110. document.write(">" + count);
  111. }
  112. else {
  113. document.write(" ");
  114. }
  115. }
  116. if (linktrue)
  117. document.write("</a>");
  118. document.write("</td>");
  119. count++;
  120. }
  121. document.write("</tr>");
  122. document.write("<tr>");
  123. startspaces=0;
  124. }
  125. document.write("</table></p>");
  126. // End -->
  127. </script>

Donde esta el fallo?