Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/09/2003, 02:03
BLACK RIVER
Invitado
 
Mensajes: n/a
Puntos:
Pregunta mostrando cantidad de registros

Hola, acabo de crear un sistema de comentarios bastante bonito, la he puesto para las noticias pero quisiera poner debajo d cada noticia los comentarios que hay en esa id. osea que me muestre los comentarios que hay en una id.

el problema creo q es q tengo los comentarios y las noticias en diferentes tablas y por eso creo q va a ser más chungo.

os dejo mis dos tablas:

Noticias:
Código PHP:
CREATE TABLE cm4anotis (
id int(11NOT NULL  auto_increment primary key,
tema char(255NOT NULL,
titulo text NOT NULL,
noticia text NOT NULL,
por char(255NOT NULL,
date text NOT NULL
); 
Comentarios:
Código PHP:
CREATE TABLE cm4anotiscom (
com_id int auto_increment primary key,
noti_id char(25NULL,
tema char(100NULL,
coment text NULL,
autor char(100)
); 
y el código php de las noticias es este:
Código PHP:
<?
// Datos de conexión a la dbname
include('conex.php');

if (!isset(
$pg))
$pg 0// $pg es la pagina actual
$cantidad=6// cantidad de resultados por página
$inicial $pg $cantidad;

$pegar "SELECT * FROM cm4anotis WHERE ver='ok' ORDER BY id DESC LIMIT $inicial,$cantidad";
$cad mysql_db_query($dbname,$pegar) or die (mysql_error());

$conexiontar "SELECT * FROM cm4anotis"
$conexiontarokmysql_db_query($dbname,$conexiontar);
$total_records mysql_num_rows($conexiontarok);
$pages intval($total_records $cantidad);

// Imprimiendo los resultados
while($array mysql_fetch_array($cad)) { ?>
                                      <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#D8D8C4">
                                        <tr> 
                                          <td width="422" valign="top"> 
                                            <table width="103%" border="0">
                                              <tr valign="top"> 
                                                <td colspan="2" bgcolor="#D8D8C4"> 
                                                  <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0">
                                                    <tr> 
                                                      <td width="94%" height="18" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><? echo "$array[titulo]"?><font size="2"><strong><a name="<? echo $array['id']; ?>" id="<? echo $array['id']; ?>"></a></strong></font> 
                                                        <? if($_COOKIE['login']=="Black_River"){ ?>
                                                        </strong></font></td>
                                                      <td width="1%" valign="middle">
<table width="17" height="1" border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAA80">
                                                          <tr>
                                                            <td width="13" height="14" align="center" valign="middle"> 
                                                              <center>
                                                                <strong><a href="admin/notiborrada.php?id=<? echo $array['id']; ?>"><font size="1">X</font></a></strong> 
                                                              </center></td>
                                                          </tr>
                                                        </table> 
                                                      
                                                      </td>
                                                      <td width="5%" valign="top"> 
                                                        <? ?>
                                                      </td>
                                                    </tr>
                                                  </table>
                                                  
                                                </td>
                                              </tr>
                                              <tr> 
                                                <td width="14%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="<? echo "$array[tema]"?>" width="60" height="60"></font></td>
                                                <td width="86%"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><? echo "$array[noticia]"?></font></td>
                                              </tr>
                                              <tr bgcolor="#E6E6D0"> 
                                                <td colspan="2"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Enviado 
                                                    por <? echo "$array[por]"?> 
                                                    el d&iacute;a <? echo "$array[date]"?> 
                                                    horas | [<a href="ver.php?id=<? echo $row['id']; ?>">leer 
                                                    m&aacute;s</a>] </font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                                            </font></div></td>
                                              </tr>
                                            </table>
                                          </td>
                                        </tr>
                                      </table>
                                      <br> 
                                      <? } ............AQUÍ SEGUIRÍA UN CÓDIGO DE PAGINACIÓN.................. ?>
veis el "LEER MÁS"??? pos detrás de ese corchete quiero que aparezca:
Comentarios: $cantidad

o como sea.

no sé como ponerlo, porque están los datos en dos tablas diferentes. a ver si me podéis solucionar esto.

Ah por cierto, el id de la noticia en la tabla de cm4anotis es "id" y en cm4anotiscom es "noti_id"

enga un saludo

Última edición por BLACK RIVER; 28/09/2003 a las 02:05