PHP - MOSTRAR COMENTARIOS EN TABLAS

 
Vista:

MOSTRAR COMENTARIOS EN TABLAS

Publicado por José D. Ruiz (5 intervenciones) el 30/05/2007 23:56:34
Hola, quiero q en una seccion de comentarios con base de datos me aparesca una tabla por cada comentario (datos: nombre, email, comentario, pais) en orden descendente y anidadas y q cambie d color de forma alternada: gris y blanco en el fondo d cada tabla por cada comentario q llegue. Pero al ejecutarlo me dice este error:

Parse error: parse error, unexpected T_STRING in c:\archivos de programa\easyphp1-7\www\losdiezmandamientos\vercomentarios.php on line 70

y la linea 70 es:

1
<td><div align="left"><strong>Nombre: </strong><?php $echo row[0];?> <strong>E-mail:</strong><?php echo $row[1];?></div></td>

pero no encuentro el error. Tambien quiero q me guarde la fecha d cada comentario en la base d datos y mostrarla pero no se como. Si me pueden ayudar....Se lo agradeceria mucho...

El form es:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<form action="confirmacomentario.php" method="post" enctype="multipart/form-data" name="form1">
        <table width="200" border="3" bordercolor="#62887D">
          <tr>
            <td bordercolor="#030303"><table width="415" border="0" bgcolor="#E9E9E9">
                <tr>
                  <td class="Estilo20"><div align="right">*Nombre para mostrar: </div></td>
                  <td width="180"><center>
                      <input name="nombre" type="text" id="nombre" size="30">
                  </center></td>
                </tr>
                <tr>
                  <td height="24" class="Estilo20"><div align="right">Email:</div></td>
                  <td><center>
                      <input name="email" type="text" id="email" size="30">
                  </center></td>
                </tr>
                <tr>
                  <td height="24" class="Estilo20"><div align="right">
                      <p>*Comentario:</p>
                      <p> </p>
                      <p>  </p>
                      <p> </p>
                      <p> </p>
                      <p> </p>
                  </div></td>
                  <td><textarea name="comentario" cols="26" rows="10" id="comentario"></textarea></td>
                </tr>
                <tr>
                  <td class="Estilo20"><div align="right">*País de procedencia: </div></td>
                  <td><input name="pais" type="text" id="pais" size="30"></td>
                </tr>
                <tr>
                  <td><p align="right">
                      <input name="Enviar" type="submit" id="Enviar" value="Enviar">
                  </p></td>
                  <td><input name="Borrar" type="reset" id="Borrar" value="Borrar"></td>
                </tr>
            </table></td>
          </tr>
        </table>
        <p>*Datos obligatorios </p>
</form>

Mi archivo .php es:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
<head>
<title>Problema</title>
</head>
<body>
<html>
<body>
<?php
$conexion=mysql_connect("localhost","root","") or
  die("Problemas en la conexion");
mysql_select_db("comentarios",$conexion) or
  die("Problemas en la selección de la base de datos");
$registros=mysql_query("select nombre,email,comentario,pais
                       from usuarios",$conexion) or
  die("Problemas en el select:".mysql_error());
 
$c=0;
$color=0;
 
while ($row = mysql_fetch_row($registros))
{ $c=$c+1;
}
 
if($c>0)
{
$registros=mysql_query("select nombre,email,comentario,pais
                       from usuarios",$conexion) or
  die("Problemas en el select:".mysql_error());
 
 while ($row = mysql_fetch_row($registros))
 {
        ?>
 
  <table width="618" border="0">"
       <tr>
          <td width="612"><div align="left">
              <table width="612" border="0" bgcolor="#E6E6E6">
                <tr>
                  <td><div align="left"><strong>Nombre: </strong><?php echo $row[0];?> <strong>E-mail:</strong><?php echo $row[1];?></div></td>
                </tr>
                <tr>
                  <td><div align="left"></div></td>
                </tr>
                <tr>
                  <td><div align="left"><?php echo $row[2];?> </div></td>
                </tr>
                <tr>
                  <td><div align="left">
                      <p><strong>País de procedencia:</strong> <?php echo $row[3];?></p>
                  </div></td>
                </tr>
              </table>
            </div>
              <div align="left"></div></td>
        </tr>
        <tr>
          <td><div align="left"></div>
              <div align="left">
<?php $color=1; break;
 }
   if($c>1)
   {
    while ($row = mysql_fetch_row($registros))
    {
 
    do
      {   ?>
       <table width="612" border="0" <?php if($color==0){?>bgcolor="#E6E6E6"<?php }?>>
                <tr>
                  <td><div align="left"><strong>Nombre: </strong><?php $echo row[0];?> <strong>E-mail:</strong><?php echo $row[1];?></div></td>
                </tr>
                <tr>
                  <td><div align="left"></div></td>
                </tr>
                <tr>
                  <td><div align="left"><?php echo $row[2];?> </div></td>
                </tr>
                <tr>
                  <td><div align="left">
                      <p><strong>País de procedencia:</strong> <?php echo $row[3];?></p>
                  </div></td>
                </tr>
              </table>
            </div>
              <div align="left"></div></td>
        </tr>
        <tr>
          <td><div align="left"></div>
              <div align="left">
 
         <?php $color=0;
 
         }while ($row = mysql_fetch_row($registros))
      break;
      }
   ?>
 
    </div></td>
        </tr>
      </table>
 
<?php
    }
}
else
{
echo "No hay comentarios.";
}
mysql_close($conexion);
?>
 
</body>
</html>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:MOSTRAR COMENTARIOS EN TABLAS

Publicado por Diego Romero (1450 intervenciones) el 31/05/2007 16:12:17
Donde dice:
<?php $echo row[0];?>

debería decir:
<?php echo $row[0];?>

Tienes el símbolo $ en el lugar incorrecto :).
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:MOSTRAR COMENTARIOS EN TABLAS

Publicado por José D. Ruiz (5 intervenciones) el 01/06/2007 04:22:19
AHH YA ME DI CUENTA DEL ERROR GRACIAS POR DECIRMELO. Era un error peqeño pero q m causaba problemas. Gracias Diego.....
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar