Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/08/2011, 07:39
warbandit69
 
Fecha de Ingreso: diciembre-2008
Ubicación: http://www.solucionesrios.tk/
Mensajes: 413
Antigüedad: 15 años, 4 meses
Puntos: 19
Pregunta Renderizado para construir tabla dinamica con adodb

Buenos Dias foreros, gracias por leer mi post, espero me ayuden

Estoy realizando las bases de un proyecto con Adodb, y paginación con arreglos, todo bien, pero tengo un pequeño problema con la renderizacion.

Me funciona solo con el primer elemento que especifico, y con el segundo en adelante no me funciona.

Les coloco el codigo de la funcion completa

Código PHP:
function Construye_Tabla($query_a_ejecutar,$campos,$columnas,$renderizacion,$inicio,$enlace,$estilo_tabla,$titulos)
{
    
$db conectarse();
    
$campo explode(",",$campos);
    
$renders explode(",",$renderizacion);
    if (
count($renders)!=count($campo)) {
        echo 
"ERROR Construye_Tabla (1)";
        exit();    
    }
    for (
$l=0;$l<count($renders);$l++)
    {
        
$render[$l][$renders[$l]] = explode(":",$renders[$l]);
    }
    
$arreglo Consulta($query_a_ejecutar,$campos);
    
$perpage $columnas
    if(isset(
$inicio)) 
        
$start $inicio
    else 
        
$start 0;
    
$numposts count($arreglo);
    
$data array_slice($arreglo$start$perpage);
    if (
$estilo_tabla!=""
    {
        
$tabla "<table align='center' style='".$estilo_tabla."'>";
    } else {
        
$tabla "<table align='center' >";
    }
    if (
$titulos=="Y"
    {
        
$tabla .= "<tr>";
        for (
$i=0;$i<count($campo);$i++)
        {
            
$tabla .= "<th>";
            
$tabla .= $campo[$i];
            
$tabla .= "</th>";
        }
    }
    
$tabla .= "</tr>";

    foreach(
$data as $k => $v)
    {
        
$tabla .= "<tr>";
        for (
$m=0;$m<count($campo);$m++)
        {
            
$tabla .= "<td>";
            
$dato =  $data[$k][$campo[$m]];
            if (
$render[$m][$renders[$m]][0] == $campo[$m]) {
                if (isset(
$render[$m][$renders[$m]][1])) {
                    
$dato str_replace("%".$campo[$m]."%",$data[$k][$campo[$m]],$render[$m][$renders[$m]][1]);    
                }
            }
            
$tabla .= $dato;
            
$tabla .= "</td>";
        }
        
$tabla .= "</tr>";
    }
    
$tabla .= "</table><br />";
    
    
$text "<table align='center'><tr>";
    if(
$start 0)
    {
        
$text .= "<td><a href='".$enlace."?start=0'>
        <img src='imagenes/First.gif' /> 
        </a></td><td><a href='"
.$enlace."?start=".($start $perpage)."'>
        <img src='imagenes/Previous.gif' /> 
        </a></td>
        "
;
    }
    if(
$start && $numposts $perpage && $start $numposts $perpage)
    {
        
$text .= "";
    }
    if(
$numposts $perpage && $start $numposts $perpage)
    {
        
$total count($arreglo);
        
$paginas $total $columnas;
        
$p 0;
        
$q 0;
        for (
$n=0;$n<$paginas;$n++)
        {
            if (
$n<$paginas
            {
                
$p $n;    
            }
            for (
$o=0;$o<$columnas;$o++)
            {
                
                if ((
$p == $n) && ($o == 0))
                {
                    
$ultimo $q;    
                }
                
$q $q+1;
            }
        }
        
$text .= "<td><a href='".$enlace."?start=".($start $perpage)."'>
        <img src='imagenes/Next.gif' />
        </a></td><td><a href='"
.$enlace."?start=".$ultimo."'>
        <img src='imagenes/Last.gif' /> 
        </a></td>"
;
    }
    
$text .= "</tr></table>";
    
$tabla .= "<center>".$text."</center>";
    
    
    
$db->Close();
    return 
$tabla;

Para resumir se que el problema esta en este fragmento

Código PHP:
foreach($data as $k => $v)
    {
        
$tabla .= "<tr>";
        for (
$m=0;$m<count($campo);$m++)
        {
            
$tabla .= "<td>";
            
$dato =  $data[$k][$campo[$m]];
            if (
$render[$m][$renders[$m]][0] == $campo[$m]) {
                if (isset(
$render[$m][$renders[$m]][1])) {
                    
$dato str_replace("%".$campo[$m]."%",$data[$k][$campo[$m]],$render[$m][$renders[$m]][1]);    
                }
            }
            
$tabla .= $dato;
            
$tabla .= "</td>";
        }
        
$tabla .= "</tr>";
    } 
Llamo la funcion de la siguiente forma:

Código PHP:
echo  Construye_Tabla(
"SELECT `id`  AS 'ID', `title` AS 'TITULO', `note` AS 'NOTAS'
FROM `todolist`"
,
"ID,TITULO,NOTAS",
2,
"ID:<a href='prueba.php?recordID=%ID%' target='_top'>%ID%</a>,TITULO:<p style='color:red'>%TITULO%</p>,NOTAS:<p style='color:green'>%NOTAS%</p>",
$_GET['start'],
"index.php",
"",
"Y") ; 
La parte de renderizar la especifico en esta linea

"ID:<a href='prueba.php?recordID=%ID%' target='_top'>%ID%</a>,TITULO:<p style='color:red'>%TITULO%</p>,NOTAS:<p style='color:green'>%NOTAS%</p>"

Cualquier duda que tengan respondanme a este post, estare pendiente todo el tiempo, gracias y saludos
__________________
http://www.solucionesrios.tk/

Visita mi Web!