Foros del Web » Creando para Internet » CSS »

Establecer anchura de tabla html creada con php

Estas en el tema de Establecer anchura de tabla html creada con php en el foro de CSS en Foros del Web. Buenos días: He recurrido a un código que he encontrado en internet link: https://www.youtube.com/watch?v=FucYLYJ1D4M Lo he adaptado a mi base de datos Mysql y funciona. ...
  #1 (permalink)  
Antiguo 11/02/2015, 11:20
 
Fecha de Ingreso: noviembre-2005
Mensajes: 146
Antigüedad: 18 años, 5 meses
Puntos: 1
Establecer anchura de tabla html creada con php

Buenos días:
He recurrido a un código que he encontrado en internet
link: https://www.youtube.com/watch?v=FucYLYJ1D4M
Lo he adaptado a mi base de datos Mysql y funciona.
El problema es que no puedo dimensionar la anchura de la tabla.
El código es:
Código PHP:

Código PHP:
Ver original
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta   charset="utf-8">
  5.     <title>Solicitudes</title>
  6. </head>
  7. <body>
  8. <?php
  9. include("conexion.php");
  10.  
  11. echo "<table border=1>
  12. <tr>
  13.    <th>IdServ</th>
  14.    <th>Ref_Pres</th>
  15.    <th>Ref_Serv</th>
  16.    <th>Tiempo</th>
  17.    <th>Usuarios</th>
  18.    <th>HoraI</th>
  19.    <th>HoraII</th>
  20.    <th>Reserva</th>
  21.    <th>Precio</th>
  22.    <th>Coste</th>
  23.    <th>Sumprecio</th>
  24.    <th>Sumcoste</th>
  25.    <th>Acron</th>
  26. </tr>";
  27. while($record = mysqli_fetch_array($myData)){
  28. echo "<form action=form_solicitudes.php method=post>";
  29. echo "<tr>";
  30. echo "<td>" . "<input type=text class= 'min' name=txtIdpres_Serv    value=" . $record['Idpres_Serv'] . " </td>";
  31. echo "<td>" . "<input type=text class= 'min' name=txtRef_Pres       value=" . $record['Ref_Pres'] . " </td>";
  32. echo "<td>" . "<input type=text class= 'min' name=txtRef_Serv       value=" . $record['Ref_Serv'] . " </td>";
  33. echo "<td>" . "<input type=text class= 'min' name=txtTiempo         value=" . $record['Tiempo'] . " </td>";
  34. echo "<td>" . "<input type=text class= 'min' name=txtUsuarios       value=" . $record['Usuarios'] . " </td>";
  35. echo "<td>" . "<input type=text class= 'min' name=txtHoraI          value=" . $record['HoraI'] . " </td>";
  36. echo "<td>" . "<input type=text class= 'min' name=txtHoraII         value=" . $record['HoraII'] . " </td>";
  37. echo "<td>" . "<input type=text class= 'min' name=txtReserva        value=" . $record['Reserva'] . " </td>";
  38. echo "<td>" . "<input type=text class= 'min' name=txtPrecio         value=" . $record['Precio'] . " </td>";
  39. echo "<td>" . "<input type=text class= 'min' name=txtCoste          value=" . $record['Coste'] . " </td>";
  40. echo "<td>" . "<input type=text class= 'min' name=txtSumprecio      value=" . $record['Sumprecio'] . " </td>";
  41. echo "<td>" . "<input type=text class= 'min' name=txtSumcoste       value=" . $record['Sumcoste'] . " </td>";
  42. echo "<td>" . "<input type=text class= 'min' name=txtAcron          value=" . $record['Acron'] . " </td>";
  43.  
  44.  
  45.  
  46. echo "<td>" . "<input type=hidden name=hidden value=" . $record['Idpres_Serv'] . " </td>";
  47. echo "<td>" . "<input type=submit name=update value=update" . " </td>";
  48. echo "<td>" . "<input type=submit name=delete value=delete" . " </td>";
  49. echo "</tr>";
  50. echo "</form>";
  51. }
  52. echo "<form action=solicitudes.php method=post>";
  53. echo "<tr>";
  54. echo "<td><input type=text class= 'min' name=txtIdpres_Serv></td>";
  55. echo "<td><input type=text class= 'min' name=txtRef_Pres></td>";
  56. echo "<td><input type=text class= 'min' name=txtRef_Serv></td>";
  57. echo "<td><input type=text class= 'min' name=txtTiempo></td>";
  58. echo "<td><input type=text class= 'min' name=txtUsuarios></td>";
  59. echo "<td><input type=text class= 'min' name=txtHoraI></td>";
  60. echo "<td><input type=text class= 'min' name=txtHoraII></td>";
  61. echo "<td><input type=text class= 'min' name=txtReserva></td>";
  62. echo "<td><input type=text class= 'min' name=txtPrecio></td>";
  63. echo "<td><input type=text class= 'min' name=txtCoste></td>";
  64. echo "<td><input type=text class= 'min' name=txtSumprecio></td>";
  65. echo "<td><input type=text class= 'min' name=txtSumcoste></td>";
  66. echo "<td><input type=text class= 'min' name=txtAcron></td>";
  67.  
  68.  
  69. echo "<td>" . "<input type=submit name=add value=add" . " </td>";
  70. echo "</form>";
  71. echo "</table>";
  72.  
  73. ?>
  74.  
  75. </body>
  76. </html>


La linea 11 inicia la tabla.
He usado:
Código PHP:
Código PHP:
Ver original
  1. echo <table border=1 width=50%>
Código PHP:
Ver original
  1. echo <table border=1 width=500>
Código PHP:
Ver original
  1. echo <table border=1 width=500px>
Código PHP:
Ver original
  1. echo <table border=1 width='500px'>
Código PHP:
Ver original
  1. echo <table border=1 width="500px">

y así sucesivamente.

Espero que alguien sepa como puedo hacerlo y la explicación de qué hago mal.
Gracias
  #2 (permalink)  
Antiguo 11/02/2015, 11:34
Avatar de fede5426  
Fecha de Ingreso: diciembre-2014
Ubicación: Córdoba
Mensajes: 446
Antigüedad: 9 años, 4 meses
Puntos: 208
Respuesta: Establecer anchura de tabla html creada con php

Te recomiendo que lo hagas con CSS. Asignale un identificador o una clase y luego con CSS le aplicas el border y el width.

Código PHP:
Ver original
  1. echo '<table id="tabla1">';

Código CSS:
Ver original
  1. #tabla1{
  2.     border: 1px solid #000;
  3.     width: 500px;
  4. }

Saludos
  #3 (permalink)  
Antiguo 11/02/2015, 12:38
 
Fecha de Ingreso: noviembre-2005
Mensajes: 146
Antigüedad: 18 años, 5 meses
Puntos: 1
Respuesta: Establecer anchura de tabla html creada con php

Gracias por tu respuesta.
También lo intenté desde CSS.
Inserté

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2.     <meta   charset="utf-8">
  3.     <title>Solicitudes</title>
  4.  
  5.     <link   rel="stylesheet" type="text/css" href="formulario.css">
  6. </head>

Pero no aplica los atributos. Y al desplazar el border = 1 al script "formulario.css
desaparece el borde de la tabla.

Etiquetas: establecer, html, input, php, tabla
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 17:44.