Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/07/2010, 23:39
jh0sz
 
Fecha de Ingreso: mayo-2010
Mensajes: 60
Antigüedad: 13 años, 11 meses
Puntos: 0
Respuesta: [Duda]Instanciar un objeto de una clase datos

Cita:
Iniciado por GatorV Ver Mensaje
De la misma manera, getDato te regresa un array y puedes leerlo usando sus indices.

Saludos.
Bro sigo todos los pasos que me dices pero no encuentro donde está la falla xq no me da errores sino que no me trae los valores :(

Le podrias hechar una ojeada a ver donde esta la falla? Aca te dejo el code... Gracias

index.php
Código:
<html>
<head>
<title>Zapateria JR</title>
</head>
<body bgcolor="#0000FF">
<center>
<font color="#FFFFFF">
<h1>.::Sistema de Zapateria JR System::.</h1>
<h2><i>Tu Mejor Eleccion</i>...</h2>
<hr>
</font>
<form name="form1" method="post" action="consulta.php">
  <table width="223" border="0">
    <tr>
      <td><font color="#FFFFFF"><strong>MARCA:</strong></font></td>
      <td><select name="marca" id="marca" style="width: 140px">
        <option value="0">Seleccione...</option>
        <option value="puma">puma</option>
        <option value="zara">zara</option>
        <option value="nike">nike</option>
      </select></td>
    </tr>
    <tr>
      <td><font color="#FFFFFF"><strong>TALLA:</strong></font></td>
      <td><select name="talla" id="talla" style="width: 140px">
        <option value="0">Seleccione...</option>
        <?php
		for($a=35; $a<=40; $a++){
              echo "<option value='".$a."'>".$a."</option>";
            }
		?>
      </select></td>
    </tr>
  </table>
  <br>
   <input type="submit" name="consultar" id="consultar" value="Consultar Zapatos">
</form>
<hr>
</center>
</body>
</html>
consulta.php
Código:
<html>
<head>
<title>Consulta de Zapatos - JR System</title></head>
<body bgcolor="#0000FF">

<center>
<h1><font color="#FFFFFF">.::Sistema de Zapateria JR System::.</font></h1>
<hr>
<font color="#FFFFFF"><?php
include("classTabla.php");
include("arreglo_nike.php");
$marca=$_POST['marca'];
$talla=$_POST['talla'];
$f=2;
$c=1; 
?>
<h2>MARCA:
  <?php echo $_POST['marca']?>  - TALLA: 
  <?php  echo $_POST['talla'] ?>
  </h2></font>
  <hr />
<font color="#FFFFFF"><?php
if(!$marca or !$talla){
  echo "<font color='".red."'>";
  echo "<br><center><b>ATENCION, TIENES QUE LLENAR LA CONSULTA COMPLETA.</b><br><br>";
  echo "</font>";
  echo "<a href='index.php'><input type='button' name='volver' value='REGRESAR'></a></center>";
}
else {
$coun=count($cantidad[$_POST['marca']])+1;
$formato1= new Tabla($coun,2);
$formato1->cargarr(1,1,"<b>Modelo</b>");
$formato1->cargarr(1,2,"<b>Cantidad</b>");
$datos = new Datos();
$cantidad = $datos->getDato();
foreach($cantidad["$marca"] as $key=>$name)
{
$formato1->cargarr($f,$c,$key);
$c++;
$formato1->cargarr($f,$c,$cantidad["$marca"][$key]["$talla"]);
$f++;
$c--;
}
$formato1->grafica();
echo "<br />";
echo "<A href='index.php'><INPUT type='button' name='volver' value='Volver'></a></center>";
}
?>
</font></center>

</body>
</html>
classTabla.php
Código:
<?php
class Tabla {
  private $mat=array();
  private $Filas;
  private $Columnas;

  public function __construct($fi,$co)
  {
    $this->Filas=$fi;
    $this->Columnas=$co;
  }

  public function cargarr($fila,$columna,$valor)
  {
    $this->mat[$fila][$columna]=$valor;
  }

  public function mostrar($fi,$co)
  {
    echo '<td>'.$this->mat[$fi][$co].'</td>';
  }


  public function grafica()
  {
    echo '<table border=\'1\'>';
    for($f=1;$f<=$this->Filas;$f++)
    {
      echo '<tr>';
      for($c=1;$c<=$this->Columnas;$c++)
      {
         $this->mostrar($f,$c);
      }
      echo '</tr>';
    }
    echo '</table>';
  }
}

?>
arreglo_nike.php
Código:
<?php
class Datos {
	function getDato(){
   
       return $cantidad = array (
				'nike' => array (
						        'Nikea'=> array (
							                           '35' => 23,
							                           '36' => 36,
							                           '37' => 58,
							                           '38' => 27,
							                           '39' => 12,
							                           '40' => 40
                                                                                 ),
						        'Nikeb'=> array (
							                           '35' => 30,
							                           '36' => 46,
							                           '37' => 38,
							                           '38' => 27,
							                           '39' => 12,
							                           '40' => 30
                                                                                 ),
								'Nikec'=> array (
							                           '35' => 23,
							                           '36' => 16,
							                           '37' => 38,
							                           '38' => 27,
							                           '39' => 12,
							                           '40' => 40
                                                                                 ),
						        'Niked'=> array (
							                           '35' => 40,
							                           '36' => 26,
							                           '37' => 18,
							                           '38' => 47,
							                           '39' => 42,
							                           '40' => 42
                                                                                 ),
							),
				'puma' => array (
						        'PumaA'=> array (
							                           '35' => 12,
							                           '36' => 12,
							                           '37' => 33,
							                           '38' => 22,
							                           '39' => 23,
							                           '40' => 33
                                                                                 ),
						        'PumaB'=> array (
							                           '35' => 12,
							                           '36' => 32,
							                           '37' => 44,
							                           '38' => 55,
							                           '39' => 12,
							                           '40' => 22
                                                                                 ),
								'PumaC'=> array (
							                           '35' => 23,
							                           '36' => 65,
							                           '37' => 66,
							                           '38' => 55,
							                           '39' => 23,
							                           '40' => 32
                                                                                 ),
						        'PumaD'=> array (
							                           '35' => 31,
							                           '36' => 61,
							                           '37' => 18,
							                           '38' => 17,
							                           '39' => 22,
							                           '40' => 23
                                                                                 ),
							),
				'zara' => array (
						        'ZaraA'=> array (
							                           '35' => 31,
							                           '36' => 61,
							                           '37' => 23,
							                           '38' => 54,
							                           '39' => 65,
							                           '40' => 50
                                                                                 ),
						        'ZaraB'=> array (
							                           '35' => 66,
							                           '36' => 34,
							                           '37' => 23,
							                           '38' => 56,
							                           '39' => 45,
							                           '40' => 34
                                                                                 ),
								 'ZaraC'=> array (
							                           '35' => 34,
							                           '36' => 23,
							                           '37' => 13,
							                           '38' => 23,
							                           '39' => 2,
							                           '40' => 23
                                                                                 ),
						        'ZaraD'=> array (
							                           '35' => 34,
							                           '36' => 66,
							                           '37' => 45,
							                           '38' => 24,
							                           '39' => 23,
							                           '40' => 33
                                                                                 ),
							),	  
 
				);	
	}
	
	function getDatos() {
		$cantidad = $this->getDato();
		return $cantidad;
	}
}
 
?>

Saludos