Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2008, 10:30
Avatar de karlic0s
karlic0s
 
Fecha de Ingreso: abril-2007
Ubicación: Cartagena (Murcia)
Mensajes: 241
Antigüedad: 17 años, 10 meses
Puntos: 18
while dentro de while?

Bueno, pongo aquí mi código, es algo engorroso, espero que si alguien tiene tiempo me eche una mano.
Código PHP:
<?php
include_once "PHPPaging.lib.php";
$paging = new PHPPaging;

$conexion mysql_connect('localhost','root',''); 
//Seleccion de la base de datos... 
mysql_select_db('mi_base_de_datos',$conexion); 

$paging = new PHPPaging($conexion);

$q "select * from noticias order by fecha Desc";

$paging->agregarConsulta($q);

mysql_connect('localhost','root','');
mysql_select_db('mi_base_de_datos');
$sql "select * from noticias order by fecha Desc";

include_once 
'PHPPaging.lib.php';
$paging = new PHPPaging;

$paging->agregarConsulta($sql);

$paging->ejecutar();

while(
$datos $paging->fetchResultado()) {

$texto "$datos[noticia]"
$texto substr($texto0300);


$result2=mysql_query("select * from comentarios where id",$connect);
$totalcomentarios=mysql_num_rows($result2);

while(
$row=mysql_fetch_array($result))
{

$result2=mysql_query("select * from comentarios where id='".$row[id_noticia]."'",$connect);
$totalcomentarios=mysql_num_rows($result2);


echo 
'
        <table width="400" cellspacing="0" cellpadding="0" border="0">
        <tr>
        <td background="images/cuentat_16.jpg" width="15" height="32">
        </td>
        <td background="images/cuentat_17.jpg" width="*" height="32" class="titulo">

            De: '
.$datos['autor'].', publicado el dia '.$datos['fecha'].'

        </td>
        <td background="images/cuentat_19.jpg" width="15" height="32">
        </td>
        </tr>
        <tr>
        <td width="15" height="165" class="mensajes1">
        </td>
        <td width="*" height="165" class="mensajes2">
            <h3><a class="linki" href="ver.php?id='
.$datos[id_noticia].'">'.$datos['titulo'].'</a></h3>

            '
.$texto.'... <a class="linki4" href="ver.php?id='.$datos[id_noticia].'">(Leer más)</a> 
        <br><br>
             
            <a class="linki4" href="ver.php?id='
.$datos[id_noticia].'">Respuestas: ('.$totalcomentarios.')</a><br><br>

        </td>
        <td width="15" height="165" class="mensajes3">
        </td>
        </tr>
        </table><br>
'
;
}
}
mysql_free_result($result)
$links $paging->fetchNavegacion();

//Una cadena conteniendo el codigo HTML de la barra de 
//navagación es generada y guardada en la variable $links.

echo $links;

?>
En cambio, quitando lo de totalcomentarios me funciona perfectamente, es decir, asi:

Código PHP:
<?php
include_once "PHPPaging.lib.php";
$paging = new PHPPaging;

$conexion mysql_connect('localhost','root',''); 
//Seleccion de la base de datos... 
mysql_select_db('mi_base_de_datos',$conexion); 

$paging = new PHPPaging($conexion);

$q "select * from noticias order by fecha Desc";

$paging->agregarConsulta($q);

mysql_connect('localhost','root','');
mysql_select_db('mi_base_de_datos');
$sql "select * from noticias order by fecha Desc";

include_once 
'PHPPaging.lib.php';
$paging = new PHPPaging;

$paging->agregarConsulta($sql);

$paging->ejecutar();

while(
$datos $paging->fetchResultado()) {

$texto "$datos[noticia]"
$texto substr($texto0300);

echo 
'
        <table width="400" cellspacing="0" cellpadding="0" border="0">
        <tr>
        <td background="images/cuentat_16.jpg" width="15" height="32">
        </td>
        <td background="images/cuentat_17.jpg" width="*" height="32" class="titulo">

            De: '
.$datos['autor'].', publicado el dia '.$datos['fecha'].'

        </td>
        <td background="images/cuentat_19.jpg" width="15" height="32">
        </td>
        </tr>
        <tr>
        <td width="15" height="165" class="mensajes1">
        </td>
        <td width="*" height="165" class="mensajes2">
            <h3><a class="linki" href="ver.php?id='
.$datos[id_noticia].'">'.$datos['titulo'].'</a></h3>

            '
.$texto.'... <a class="linki4" href="ver.php?id='.$datos[id_noticia].'">(Leer más)</a> 
        <br><br>
             
            <a class="linki4" href="ver.php?id='
.$datos[id_noticia].'">Respuestas: ('.$totalcomentarios.')</a><br><br>

        </td>
        <td width="15" height="165" class="mensajes3">
        </td>
        </tr>
        </table><br>
'
;
}
$links $paging->fetchNavegacion();

//Una cadena conteniendo el codigo HTML de la barra de 
//navagación es generada y guardada en la variable $links.

echo $links;

?>
El error he de tenerlo aquí:


$result2=mysql_query("select * from comentarios where id",$connect);
$totalcomentarios=mysql_num_rows($result2);

while($row=mysql_fetch_array($result))
{

$result2=mysql_query("select * from comentarios where id='".$row[id_noticia]."'",$connect);
$totalcomentarios=mysql_num_rows($result2);


echo '
<table widt...

pero no se donde :S


Saludos!