Foros del Web » Programando para Internet » PHP »

como mostrar el contenido de un registro en una tablas html

Estas en el tema de como mostrar el contenido de un registro en una tablas html en el foro de PHP en Foros del Web. bueno estoy intentando mostrar los datos que tengo en mi base pero me tira error me gustaría saber si me pueden ayudar mi base se ...
  #1 (permalink)  
Antiguo 17/03/2013, 12:08
 
Fecha de Ingreso: julio-2010
Mensajes: 5
Antigüedad: 13 años, 9 meses
Puntos: 0
Información como mostrar el contenido de un registro en una tablas html

bueno estoy intentando mostrar los datos que tengo en mi base pero me tira error
me gustaría saber si me pueden ayudar
mi base se llama: tatos}la tabla es:
TABLE ARTICULOS (
ID_ARTICULOS INTEGER NOT NULL,
DESCRIPCION VARCHAR (30) ,
MARCA VARCHAR (30) ,
PRECIO FLOAT);
este es el código que estoy utilizando pero no logro que me muestre los datos
si alguien sabe porque se los agradezco
bueno acá esta

<html>
<body>
<?php


$conx = mysql_connect ("localhost","root","","tatos");
if (!$conx) die ("Error al abrir la base <br/>". mysql_error());
mysql_select_db("test") OR die("Connection Error to Database");


$sql="select * from articulos";
$result= mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result)==0) die("No hay registros para mostrar");


echo "<table border=1 cellpadding=4 cellspacing=0>";

echo "<tr>
<th colspan=5> ARTICULOS</th>
<tr>
<th> id_articulos </th><th> descripcion </th>
<th> marca </th><th> precio </th>
</tr>";


while($row=mysql_fetch_array($result))
{
echo "<tr>
<td align='right'> $row[id_articulos] </td>
<td> $row[descripcion] </td>
<td> $row[marca] </td>
<td> $row[precio] </td>
</tr>";
}
echo "</table>";

?>
</body>
</html>


BUENO ESO ES TODO SOY NUEVO EN ESTO ESPERO QUE ME PUEDAN AYUDAR
GRACIAS
  #2 (permalink)  
Antiguo 17/03/2013, 12:23
 
Fecha de Ingreso: septiembre-2011
Mensajes: 219
Antigüedad: 12 años, 7 meses
Puntos: 31
Respuesta: como mostrar el contenido de un registro en una tablas html

Tenes un error en la linea 8 de tu código:

Código PHP:
Ver original
  1. mysql_select_db("test") OR die("Connection Error to Database");

Tu base se llama "tatos" no "test".

Saludos
  #3 (permalink)  
Antiguo 17/03/2013, 12:42
 
Fecha de Ingreso: julio-2010
Mensajes: 5
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: como mostrar el contenido de un registro en una tablas html

lo cambie pero aun no logro que me muestre los datos
puede que haya otro error ???
<html>
<body>
<?php


$conx = mysql_connect ("localhost","root","","tatos");
if (!$conx) die ("Error al abrir la base <br/>". mysql_error());
mysql_select_db("tatos") OR die("Connection Error to Database");


$sql="select * from articulos";
$result= mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result)==0) die("No hay registros para mostrar");


echo "<table border=1 cellpadding=4 cellspacing=0>";

echo "<tr>
<th colspan=5> ARTICULOS</th>
<tr>
<th> id_articulos </th><th> descripcion </th>
<th> marca </th><th> precio </th>
</tr>";


while($row=mysql_fetch_array($result))
{
echo "<tr>
<td align='right'> $row[id_articulos] </td>
<td> $row[descripcion] </td>
<td> $row[marca] </td>
<td> $row[precio] </td>
</tr>";
}
echo "</table>";

?>
</body>
</html>


muchas gracias por ayudarme
  #4 (permalink)  
Antiguo 17/03/2013, 13:36
 
Fecha de Ingreso: septiembre-2011
Mensajes: 219
Antigüedad: 12 años, 7 meses
Puntos: 31
Respuesta: como mostrar el contenido de un registro en una tablas html

Nop, salvo que tengas un error en los datos de conexión (usuario, contraseña), el código debería funcionar sin inconvenientes. Lo replique en mi servidor y me mostro la tabla.

Etiquetas: contenido, html, mysql, registro, select, sql, tabla, tablas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:08.