Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/11/2009, 15:07
Hidek1
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: while, tablas y mysql en php

nose si te sirva. la ise cuando era mas chiquitito :B

Código php:
Ver original
  1. <?php
  2. /****************************************
  3.  ** Tabla Maker by Hidek1.-
  4.  ** Licencia GNU
  5.  ****************************************
  6.  ** Versi�n 0.1b
  7.  ** Fecha de creaci�n 05 Septiembre 2007
  8.  ****************************************/
  9. class table{
  10.   var $tabla;
  11.   var $cols;
  12.   function newHeaders($arr_headers,$name,$border="",$cellpadding="",$cellspacing=""){
  13.     $border = ($border !== "") ? " border=\"$border\"" : "";
  14.     $cellpadding = ($cellpadding !== "") ? " cellpadding=\"$cellpadding\"" : "";
  15.     $cellspacing = ($cellspacing !== "") ? " cellspacing=\"$cellspacing\"" : "";
  16.     if(!$this->cols){
  17.       $this->cols = count($arr_headers);
  18.     }
  19.     $this->tabla = $this->tabla . "<table id=\"$name\" name=\"$name\"$border$cellpadding$cellspacing>\n<tr>\n";
  20.     foreach($arr_headers as $headers){
  21.       $this->tabla = $this->tabla . "\t<th>$headers</th>\n";
  22.     }
  23.     $this->tabla = $this->tabla . "</tr>\n<tr>\n";
  24.     return $this->tabla;
  25.   }
  26.   function newData($arr_data){
  27.     $celda = 1;
  28.     foreach($arr_data as $data){
  29.       $this->tabla = $this->tabla . "\t<td>$data</td>\n";
  30.       if($celda &#37; $this->cols == 0){
  31.        $this->tabla = $this->tabla . "</tr>\n<tr>\n";
  32.       }
  33.       $celda++;
  34.     }
  35.     return $this->tabla;
  36.   }
  37.   function showTable(){
  38.     $this->tabla = $this->tabla . "</tr>\n</table>";
  39.     echo $this->tabla;
  40.   }
  41. }
  42. /**** MODO DE USO ****\
  43. $tabla = new table;
  44.  
  45. $arr_headers = array("Head1","Head2","Head3","Head4","Head5");
  46. $arr_datos = array("dato1","dato2","dato3","dato4","dato5","dato6","dato7","dato8");
  47.  
  48. $tabla->newHeaders($arr_headers,"test",1,0,0); //(arrayHeaders,[border],[cellspadding],[cellspacing])
  49. $tabla->newData($arr_datos); //(arrayDatos)
  50. $tabla->showTable(); //Imprime los datos en pantalla
  51. */
  52. ?>

% cambialo por un signo de porcentaje el foro lo cambia nose porque.... en la linea 30
__________________
More about me...
~ @rhyudek1
~ Github