Hola actualmente estoy teniendo un problema...
yo tengo tres archivos uno principal php que selecciona un cliente o fecha, un ajax que pasa el dato y activa , y otro php de clientes con fecha de ingreso que me se muestra en un div.
Primer archivo
<?php
include_once( "conexion.php" );
$link= Conectarse();
mysql_select_db( "lg", $link );
mysql_select_db( "cl", $link );
$nombre = $_GET["nom"];
$construido="
</div>
<strong></strong>
<form id='clientes' name='clientes' method='POST' action=''>
<label for='select'></label>
<p class='nuevo'>
<select name='optclientes' class='nuevo' id='optclientes' onChange='carga_act();'>";
$IdCli = $_GET["IdC_li"];
$Consult= mysql_query('SELECT * FROM clientes ORDER BY C_li;');
$IdCliEle=0;
$combo="";
while($row=mysql_fetch_array($Consult))
{
if($IdCli==$row["IdCl"])
{
$IdCliEle=$row["IdCl"];
$CliEle=$row['C_li'];
}
else
{
$combo.= "<option value='".$row["IdCl"]."'>".$row['C_li']."</option>";
}
}
if($IdCli=="")
{
$todo.= "<option value=''>Elija el C_li</option><option value='-1'>Todos los C_lis</option>". $combo;
}
else
{
$todo.= "<option value='".$IdCliEle."'>".$CliEle."</option><option value='0'>Elija el C_li</option><option value='-1'>Todos los C_lis</option>" .$combo;
}
$todo.="</select>
<input type='checkbox' name='chkfecha' id='chkfecha' value='0' onChange='carga_act();'>
<label for='chkfecha'>Fecha entre</label>
<input type='date' name='fdde'> Hasta
<input type='date' name='fhta'>
</form>
<form id='invisible' name='invisible' method='post' action=''>
<input type='hidden' name='IdCliElegido' id='IdCliElegido' value=$IdCliEle />
</form>
<hr />
</head>";
echo ($todo);
?>
<div id='informacion' align="left">
<?php
if($IdCli!="")
{
echo("<script type='text/javascript'>carga_act()</script>");
}
?>
</body>
</html>
ajax.js que me permite que cuando yo elija un cliente me muestra los datos de la misma manera que todos, pero ahora quiero que me muestre por fecha pero no me funciona.
ajax.js
function objetoAjax(){
var xmlhttp=false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch (E){
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined'){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function carga_act(){
divResultado = document.getElementById('informacion');
clientes= document.getElementById('optclientes').value;
if(document.getElementById('chkfecha').value==1)
{
fdde = '2013-01-01 01:01:00';
fhta = '2013-01-01 01:01:00';
}
else
{
fdde = '2013-01-01 01:01:00';
fhta = '2100-01-01 23:59:59';
}
ajax = objetoAjax();
ajax.open("POST", "mdclientes.php", true);
ajax.onreadystatechange = function()
{
if (ajax.readyState==4){
divResultado.innerHTML = ajax.responseText
}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.send("clientes="+clientes+"&fdde="+fdde+"&fht a="+fhta);
}
segundo archivo.php que muestra los datos
<?php
include_once( "c.php" );
$link= Conectarse();
mysql_select_db( "lgn", $link );
mysql_select_db( "clientes", $link );
$idcliente = $_REQUEST["clientes"];
$fechadde = $_REQUEST["fdde"];
$fechahta = $_REQUEST["fhta"];
$SqlHelp="SELECT idH, IdCl, C_li, DATE_FORMAT(fecha, '%d/%m %H:%i') AS fecha, I_nf, ate, IF(LENGTH(det) > 100, CONCAT(LEFT(det, 97),'...'), det) as det, tema, IF(LENGTH(com) > 100, CONCAT(LEFT(com, 97),'...'), com) as com FROM h_dLEFT JOIN clientes USING(IdCl) WHERE (fecha between '$fechadde' AND '$fechahta')";
if($idcliente !=-1)
{
$SqlHelp.=" AND (IdCl = $idcliente)";
}
$SqlHelp.=" order by fecha desc";
$SqlImple="SELECT Id_Imp, IdCl, C_li, DATE_FORMAT(fecha, '%d/%m %H:%i') AS fecha, I_nf, IF(LENGTH(det) > 100, CONCAT(LEFT(det, 97),'...'), det) as det, tema, IF(LENGTH(com) > 100, CONCAT(LEFT(com, 97),'...'), com) as com FROM Imp LEFT JOIN clientes USING(IdCl) WHERE (fecha between '$fechadde' AND '$fechahta')";
if($idcliente !=-1)
{
$SqlImple.=" AND (IdCl = $idcliente)";
}
$SqlImple.=" order by fecha desc";
$resultado= mysql_query($SqlHelp, $link);
$resultado1= mysql_query($SqlImple, $link);
?>
</head>
<body>
<table width="1200" height="445" border="1" align="left">
<tr>
<td width="65" height="15" align="center" valign="top" class="nuevo" >
<?php
if (isset($_SESSION['k_username']))
{
echo "<form action='IUH.php?codigo=$idcliente&bton=HDk' id='boton' name='boton' method='POST' >
<input style='background-color:#999; color:#FFFFFF' type='submit' value='nuevo'/>
</form>";
?> </td>
<td width="589" align="center" valign="middle" class="nuevo">HelpDesk</td>
<td width="65" align="center" valign="top" class="nuevo"><?php
echo "<form action='IUH.php?codigo=$idcliente&bton=i' id='boton' name='boton' method='POST'>
<input style='background-color:#999; color:#FFFFFF' type='submit' value='nuevo'/>
</form>"; ?>
</td>
<td width="382" align="center" valign="middle" class="nuevo">Uso e Implementación</td>
</tr>
<tr>
<td height="414" colspan="2" valign="top">
<table width="660" height="30">
<tr>
<td width="50" align="left" valign="middle" class="nuevo2" ><strong>Fecha</strong></td>
<td width="70" align="left" valign="middle" class="nuevo2"><strong>Informó:</strong></td>
<td width="70" align="left" valign="middle" class="nuevo2"><strong>Atendió:</strong></td>
<td align="left" valign="middle" class="nuevo2"><strong>Tema</strong></td>
<td width="170" align="left" valign="middle" class="nuevo2"><strong>Detalle </strong></td>
<td width="30" align="left" valign="middle"> </td>
<td width="30" align="left" valign="middle"> </td>
</tr>
<?php
while ($row=mysql_fetch_array($resultado))
{
if($idcliente==-1)
{
$temaaux= $row["C_li"] . " - " . $row["tema"];
}
else
{
$temaaux=$row["tema"];
}
printf("<tr>
<td class='nuevo3'>%s</td>
<td class='nuevo3'>%s</td>
<td class='nuevo3'>%s</td>
<td class='nuevo3'>%s</td>
<td class='nuevo3'>%s</td>
<td class='nuevo3'><a href=\"M.php?Idm=$row[idH]&btoMod=Hp&ModCli=$idcliente\" ><img src='mod.png' width='25' height='25' /></a></td>
<td class='nuevo3'><a href=\"E.php?Idclientes=$idcliente&tipo=H&Idtipo=$ row[idH]\"><img src='imagenes/eliminar.png' width='25' height='25' /></a></td>
</tr>", $row["fecha"] , $row["I_nf"], $row["ate"], $temaaux, $row["det"], $row["IdHDk"], $row["IdCl"]);
}
?>
</table>
</td>
<td colspan="2" valign="top">
<table width="580" height="30">
<tr>
<td width="50" class="nuevo2"><strong>Fecha</strong></td>
<td width="70" align="left" valign="middle"><span class="nuevo2"><strong>Informó</strong></span><strong>:</strong></td>
<td width="220" align="left" valign="middle" class="nuevo2"><strong>Tema</strong></td>
<td width="170" align="left" valign="middle" class="nuevo2"><strong>Detalle </strong></td>
<td width="30" align="left" valign="middle" class="nuevo2"> </td>
<td width="30" align="left" valign="middle" class="nuevo2"> </td>
</tr>
<?php
while ($row=mysql_fetch_array($resultado1))
{
if($idcliente==-1)
{
$temaaux1= $row["C_li"] . " - " . $row["tema"];
}
else
{
$temaaux1=$row["tema"];
}
printf("<tr>
<td class='nuevo3'>%s</td>
<td class='nuevo3'>%s</td>
<td class='nuevo3'>%s</td>
<td class='nuevo3'>%s</td>
<td class='nuevo3'><a href=\"
M.php?Idm=$row[Id_Imp]&btoMod=Imp&ModCli=$idcliente\" ><img src='m.png' width='25' height='25' /></a></td>
<td class='nuevo3'><a href=\"E.php?Idc=$idcliente&tipo=Imp&Idtipo=$row[Id_Imp]\"><img src='e.png' width='25' height='25' /></a></td>
</tr>", $row["fecha"], $row["I_nf"], $temaaux1, $row["det"], $row["idImp"], $row["IdCl"]);
}
}
else
{
}
?>
</table>
</td>
</tr>
</table>
<blockquote>
</blockquote>
</body>
</html>