Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/03/2010, 05:07
kukinogi
 
Fecha de Ingreso: marzo-2010
Mensajes: 10
Antigüedad: 14 años, 1 mes
Puntos: 0
Exclamación Problema con horario en php

Buenos dias chicos!

Estoy realizando un proyecto en el cual tengo la siguiente idea:

El usuario sube un archivo excel, y automaticamente tiene que salir un "horario" con cada celda pintada de un color segun sea el valor que hay en la tabla sql.

Lo que tengo...
El excel lo he subido al mysql pero ahora no tengo ni idea de como sacar esos datos en una tabla php para que la "pinte".
Lo que he intentado es esto:

Código:
<?php require_once('Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_localhost, $localhost);
$query_Lunes = "SELECT hoja1.ACTIVIDAD FROM hoja1 WHERE hoja1.DIA = 'Lunes' ORDER BY hoja1.HORA";
$Lunes = mysql_query($query_Lunes, $localhost) or die(mysql_error());
$row_Lunes = mysql_fetch_assoc($Lunes);
$totalRows_Lunes = mysql_num_rows($Lunes);

mysql_select_db($database_localhost, $localhost);
$query_Lunes2 = "SELECT hoja1.SALA, hoja1.HORA, hoja1.ACTIVIDAD FROM hoja1 WHERE hoja1.DIA = 'Lunes' ORDER BY hoja1.HORA";
$Lunes2 = mysql_query($query_Lunes2, $localhost) or die(mysql_error());
$row_Lunes2 = mysql_fetch_assoc($Lunes2);
$totalRows_Lunes2 = mysql_num_rows($Lunes2);

mysql_select_db($database_localhost, $localhost);
$query_HORA = "SELECT DISTINCT hoja1.HORA FROM hoja1 ORDER BY hoja1.HORA ASC";
$HORA = mysql_query($query_HORA, $localhost) or die(mysql_error());
$row_HORA = mysql_fetch_assoc($HORA);
$totalRows_HORA = mysql_num_rows($HORA);
?><!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>Documento sin título</title>
</head>

<body>
<table>
  <tr>
    <td>HORA</td>
    <td><p>SALA</p></td>
    <td>LUNES</td>
    <td>MARTES</td>
    <td>MIERCOLES</td>
    <td>JUEVES</td>
    <td>VIERNES</td>
    <td>SABADO</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_HORA['HORA']; ?></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <?php } while ($row_Lunes = mysql_fetch_assoc($Lunes)); ?>
</table>
<?php do { ?>
<?php } while ($row_Lunes = mysql_fetch_assoc($Lunes)); ?>
</body>
</html><?php
mysql_free_result($Lunes);

mysql_free_result($Lunes2);

mysql_free_result($HORA);
?>
Lo que no consigo es que me salga esto:
---------------------------------------------------------------------------------
Hora | Sala | Lunes | Martes | Miercoles | Jueves | Viernes | Sabado
--------------------------------------------------------------------------------------

08:00 | SALA1| act1 | actx.........................................

Sabeis? Entonces, con lo que he intentado si que me salen las actividades pero claro.. no se corresponden a la hora . Las columnas no tienen ninguna relacion entre ellas...

He encontrado cosas por la web pero todo son sobre calendarios semanales donde crean bucles y cosas "raras" para averiguar la fecha actual y tal.
Pero yo no necesito eso, solo que me muestre los datos en una tabla y que despues me lo pinte segun un valor que hay en la bd.

Mil gracias :)

Última edición por kukinogi; 23/03/2010 a las 09:57