Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/02/2013, 21:49
Avatar de elmoikano
elmoikano
 
Fecha de Ingreso: enero-2013
Mensajes: 50
Antigüedad: 11 años, 3 meses
Puntos: 0
Respuesta: consulta rango de fecha con funcion de calendario

esta es la segunda parte del script para el calendario
Código HTML:
	//--Utils-------------------------------------------------------------
	function fc_absoluteOffsetTop(obj) {
     	var top = obj.offsetTop;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		top += parent.offsetTop;
     		parent = parent.offsetParent;
     	}
     	return top;
     }
     
     function fc_absoluteOffsetLeft(obj) {
     	var left = obj.offsetLeft;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		left += parent.offsetLeft;
     		parent = parent.offsetParent;
     	}
     	return left;
     }
     
     function fc_firstDOW(date) {
     	var dow = date.getDay();
     	var day = date.getDate();
 		if (day % 7 == 0) return dow;
     	return (7 + dow - (day % 7)) % 7; 
     }
     
     function fc_getYear(date) {
     	var y = date.getYear();
     	if (y > 1900) return y;
     	return 1900 + y;
     }
     
     function fc_monthLength(date) {
		var month = date.getMonth();
		var totald = 30;
		if (month == 0 
			|| month == 2
			|| month == 4
			|| month == 6
			|| month == 7
			|| month == 9
			|| month == 11) totald = 31;
		if (month == 1) {
			var year = date.getYear();
			if (year % 4 == 0 && (year % 400 == 0 || year % 100 != 0))
		 		totald = 29;
			else
				totald = 28;
		}
		return totald;
     }
     
     function fc_formatToken(date, token) {
		var command = token.substring(0, 1);
		if (command == 'y' || command == 'Y') {
			if (token.length == 2) { return fc_zeroPad(date.getFullYear() % 100); }
			if (token.length == 4) { return date.getFullYear(); } 
		}
		if (command == 'd' || command == 'D') {
			if (token.length == 2) { return fc_zeroPad(date.getDate()); }
		}
		if (command == 'm' || command == 'M') {
			if (token.length == 2) { return fc_zeroPad(date.getMonth() + 1); }
			if (token.length == 3) { return fc_months[date.getMonth()]; } 
		}
		return token;
     }
     
     function fc_parseToken(date, token, value, start) {
		var command = token.substring(0, 1);
		var v;
		if (command == 'y' || command == 'Y') {
			if (token.length == 2) { 
				v = value.substring(start, start + 2);
				if (v < 70) { date.setFullYear(2000 + parseInt(v)); } else { date.setFullYear(1900 + parseInt(v)); } 
			}
			if (token.length == 4) { v = value.substring(start, start + 4); date.setFullYear(v);} 
		}
		if (command == 'd' || command == 'D') {
			if (token.length == 2) { v = value.substring(start, start + 2); date.setDate(v); }
		}
		if (command == 'm' || command == 'M') {
			if (token.length == 2) { v = value.substring(start, start + 2); date.setMonth(v - 1); }
			if (token.length == 3) { 
				v = value.substring(start, start + 3);
				var i;
				for (i = 0; i < fc_months.length; i++) {
					if (fc_months[i].toUpperCase() == v.toUpperCase()) { date.setMonth(i); }
				}
			} 
		}
     }
     
     function fc_zeroPad(num) {
		if (num < 10) { return '0' + num; }
		return num;
     }

	function fc_getObj(id) {
		if (fc_ie) { return document.all[id]; } 
		else { return document.getElementById(id);	}
	}

      function fc_setFieldValue(field, value) {
                if (field.type.substring(0,6) == 'select') {
                        var i;
                        for (i = 0; i < field.options.length; i++) {
                                if (fc_equals(field.options[i].value, value)) {
                                        field.selectedIndex = i;
                                }
                        }
                } else {
                        field.value = value;
                }
      }

      function fc_getFieldValue(field) {
                if (field.type.substring(0,6) == 'select') {
                        return field.options[field.selectedIndex].value;
                } else {
                        return field.value;
                }
      }
      
      function fc_equals(val1, val2) {
      		if (val1 == val2) return true;      		
      		if (1 * val1 == 1 * val2) return true;
      		return false;
      }
     
</script>

<style>
.fc_main { background: #DDDDDD; border: 1px solid #000000; font-family: Verdana; font-size: 10px; }
.fc_date { border: 1px solid #D9D9D9;  cursor:pointer; font-size: 10px; text-align: center;}
.fc_dateHover, TD.fc_date:hover { cursor:pointer; border-top: 1px solid #FFFFFF; border-left: 1px solid #FFFFFF; border-right: 1px solid #999999; border-bottom: 1px solid #999999; background: #E7E7E7; font-size: 10px; text-align: center; }
.fc_wk {font-family: Verdana; font-size: 10px; text-align: center;}
.fc_wknd { color: #FF0000; font-weight: bold; font-size: 10px; text-align: center;}
.fc_head { background: #000066; color: #FFFFFF; font-weight:bold; text-align: left;  font-size: 11px; }
</style>

	</head>
	<body>

		<h1>:::::::::</h1>
		
		<form action="fecha.php" method="post">
		<input size="10" id="fecha1" type="button" name="date1" title="YYYY-MM-DD" > 
		<input type="button" value="Fecha" onclick="displayCalendarFor('fecha1');">
		
		<input size="10" id="fecha2" type="button" name="date2" title="YYYY-MM-DD" > 
		<input type="button" value="Fecha" onclick="displayCalendarFor('fecha2');">
		
		<!--<input size="10" id="fecha1" type="text" name="date1" title="YYYY-MM-DD" > 
		
		<input size="10" id="fecha2" type="text" name="fecha2" title="YYYY-MM-DD" > -->
		
		<input type="submit" value="CONSULTAR" />
		</form>
		

	</body>
</html> 

y el codigo en PHP es este:

Código PHP:
<?php
        
        
Include "config.php";
            
//creo que el detalle esta en como declaro las variables de fecha
                        //pero no se como poner la variable para que postee el formato
                        //el tipo de dato es datetime
            
$q=$_POST['fecha1'];
            
$r=$_POST['fecha2'];
            
$tab1 "referencia_rapida";
            
            
$query "SELECT * FROM $tab1 WHERE fecha BETWEEN '".$q."' AND '".$r."'";
            
            
$result=mysql_query($query)
            OR DIE (
"Consulta fallida: ".mysql_error());
            
            echo 
"<TABLE BORDER = '3' id='export_excel'>";
            echo 
"<tr>";
            echo 
"<th></th>";
            echo 
"<th></th>";
            echo 
"<th align='center' colspan=4>Datos del Usuario</th>";
            echo 
"</tr>";
            echo 
"<tr>";
            echo 
"<th>Folio</th>";
            echo 
"<th>Fecha</th>";
            echo 
"<th>Nombre</th>";
            echo 
"<th>Apellido Pat</th>";
            echo 
"<th>Apellido Mat</th>";
            echo 
"<th>Matricula</th>";
            echo 
"<th>Carrera</th>";
            echo 
"<th>Semestre</th>";
            echo 
"<th>Medio</th>";
            echo 
"<th>Consulta</th>";
            echo 
"<th>Observaciones</th>";
            echo 
"<th>Resolución</th>";
            echo 
"<th>Quien atendio</th>";
            echo 
"<th>Tiempo de respuesta</th>";
            echo 
"</tr>";
            
            while (
$row mysql_fetch_array($result))
                {
                    echo 
"<tr>";
                    echo
"<td>",$row['id'],"</td>
                    <td>"
,$row['fecha'],"</td>
                    <td>"
,$row['nombre'],"</td>
                    <td>"
,$row['ap_paterno'],"</td>
                    <td>"
,$row['ap_materno'],"</td>
                    <td>"
,$row['matricula'],"</td>
                    <td>"
,$row['programa'],"</td>
                    <td>"
,$row['semestre'],"</td>
                    <td>"
,$row['medio'],"</td>
                    <td>"
,$row['descripcion'],"</td>
                    <td>"
,$row['observaciones'],"</td>
                    <td>"
,$row['resolucion'],"</td>
                    <td>"
,$row['nombre_biblio'],"</td>
                    <td>"
,$row['param'];
                    echo 
"</tr>";
                }
            echo 
"</table>";
            
        if (!
$result) {
        die(
"No exitsten Datos: " mysql_error());
        }
        
        
mysql_close($conexion)
        
?>
__________________
Bibliotecario pero morboso de las Tecnologías....