Ver Mensaje Individual
  #7 (permalink)  
Antiguo 10/08/2009, 10:30
Avatar de lukas4
lukas4
 
Fecha de Ingreso: octubre-2008
Ubicación: frente al pc
Mensajes: 496
Antigüedad: 15 años, 6 meses
Puntos: 12
hola hola que tal, yo de nuevo :D hice lo que me dijiste GatorV hice lo que me dijiste, pero tengo un problema, ya que al momento de mandarle el valor de la fecha, lo esta mandando vacio, estos son los codigos:

aqui envio el dato
Código PHP:
<?php
$link 
mysql_connect("localhost""root","");
mysql_select_db("MantoRedes",$link);

$myFile "prueba1.xml";
$fh=fopen($myFile,'w') or die("can't open file");

$query="SELECT fecha, dato, titulo FROM datostimeline WHERE nombre='lukas4'";
if(!
$busqueda=mysql_query($query,$link)){
    
mysql_error();
}
else{
    
$fecha[] = array();
    
$i=0;
    
$stringData="<?xml version=\"1.0\" encoding=\"utf-8\"?>".PHP_EOL."\t<data>".PHP_EOL."";
    
fwrite($fh,$stringData);
    while(
$row=mysql_fetch_array($busqueda)){
        
$fecha[$i]=$row['fecha'];
        
$stringData="\t<event start=\"".$row['fecha']."\" title=\"".$row['titulo']."\">".PHP_EOL."".$row['dato']."".PHP_EOL."\t</event>".PHP_EOL."";
        
fwrite($fh,$stringData);
        
$i++;
    }
}
$stringData="</data>";
fwrite($fh,$stringData);
fclose($fh);
print_r($fecha);
echo 
"<br>".$fecha[$i-1];
?>
<form action="timeline.php" method="post" id="forma">
    <input type="hidden" name="fecha" value="<?php echo $fecha[0];?>">
    <script language="javascript" type="text/javascript"><br>
    <!--
    document.getElementById("forma").submit();
    //-->
    </script>
</form>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=timeline.php">
y acá lo recibo
Código PHP:
<?php
isset($_POST['fecha']) ? $fecha=$_POST['fecha'] : $fecha=date("M d Y H:i:s");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script src="http://simile.mit.edu/timeline/api/timeline-api.js" type="text/javascript"></script>
<script>
var tl;
function onLoad() {
  var eventSource = new Timeline.DefaultEventSource();
  var bandInfos = [
    Timeline.createBandInfo({
        eventSource:    eventSource,
        date:           "<?php echo $fecha?>",//"May 01 2009 00:00:00 GMT",
        width:          "70%", 
        intervalUnit:   Timeline.DateTime.DAY, 
        intervalPixels: 100
    }),
    Timeline.createBandInfo({
        showEventText:  false,
        trackHeight:    0.5,
        trackGap:       0.2,
        eventSource:    eventSource,
        date:           "<?php echo $fecha?>",//"May 01 2009 00:00:00 GMT",
        width:          "30%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 200
    })
  ];
  bandInfos[1].syncWith = 0;
  bandInfos[1].highlight = true;
  bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());
  
  tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
  Timeline.loadXML("prueba1.xml", function(xml, url) { eventSource.loadXML(xml, url); });
}
</script>


</head>

<body onload="onLoad();" onresize="onResize();">
<br />
<div id="my-timeline" style="height:200px; border:1px solid #aaa"></div>


</body>
</html>
alguna idea del porque no esta enviando bien el dato?

oh ya lo hice trabajar, solo cambie la funcion de javascript, la funcion la puse en el onLoad y ya trabajo bien

Última edición por GatorV; 10/08/2009 a las 10:59