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:
Ver original<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Solicitudes</title>
</head>
<body>
<?php
include("conexion.php");
if(isset($_POST['update'])){ $UpdateQuery = "UPDATE solicitudes
SET Ref_Pres ='$_POST[txtRef_Pres]',
Ref_Serv ='$_POST[txtRef_Serv]',
Tiempo ='$_POST[txtTiempo]',
Usuarios ='$_POST[txtUsuarios]',
HoraI ='$_POST[txtHoraI]',
HoraII ='$_POST[txtHoraII]',
Reserva ='$_POST[txtReserva]',
Precio ='$_POST[txtPrecio]',
Coste ='$_POST[txtCoste]',
Sumprecio ='$_POST[txtSumprecio]',
Sumcoste ='$_POST[txtSumcoste]',
Acron ='$_POST[txtAcron]'
WHERE Idpres_Serv ='$_POST[txtIdpres_Serv]'";
};
if(isset($_POST['delete'])){ $DeleteQuery = "DELETE FROM solicitudes WHERE Idpres_Serv='$_POST[txtIdpres_Serv]'";
};
if(isset($_POST['add'])){ $AddQuery = "INSERT INTO solicitudes
(
Ref_Pres,
Ref_Serv,
Tiempo,
Usuarios,
HoraI,
HoraII,
Reserva,
Precio,
Coste,
Sumprecio,
Sumcoste,
Acron
)
VALUES
(
'$_POST[Ref_Pres]',
'$_POST[Ref_Serv]',
'$_POST[Tiempo]',
'$_POST[Usuarios]',
'$_POST[HoraI]',
'$_POST[HoraII]',
'$_POST[Reserva]',
'$_POST[Precio]',
'$_POST[Coste]',
'$_POST[Sumprecio]',
'$_POST[Sumcoste]',
'$_POST[Acron]'
)";
};
$sql = "SELECT * FROM solicitudes WHERE IdServ = $id_tabla";
echo "<table border=1>
<tr>
<th>IdServ</th>
<th>Ref_Pres</th>
<th>Ref_Serv</th>
<th>Tiempo</th>
<th>Usuarios</th>
<th>HoraI</th>
<th>HoraII</th>
<th>Reserva</th>
<th>Precio</th>
<th>Coste</th>
<th>Sumprecio</th>
<th>Sumcoste</th>
<th>Acron</th>
</tr>";
echo "<form action=form_solicitudes.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text class= 'min' name=txtIdpres_Serv value=" . $record['Idpres_Serv'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtRef_Pres value=" . $record['Ref_Pres'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtRef_Serv value=" . $record['Ref_Serv'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtTiempo value=" . $record['Tiempo'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtUsuarios value=" . $record['Usuarios'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtHoraI value=" . $record['HoraI'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtHoraII value=" . $record['HoraII'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtReserva value=" . $record['Reserva'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtPrecio value=" . $record['Precio'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtCoste value=" . $record['Coste'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtSumprecio value=" . $record['Sumprecio'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtSumcoste value=" . $record['Sumcoste'] . " </td>";
echo "<td>" . "<input type=text class= 'min' name=txtAcron value=" . $record['Acron'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" . $record['Idpres_Serv'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . " </td>";
echo "<td>" . "<input type=submit name=delete value=delete" . " </td>";
echo "</tr>";
echo "</form>";
}
echo "<form action=solicitudes.php method=post>";
echo "<tr>";
echo "<td><input type=text class= 'min' name=txtIdpres_Serv></td>";
echo "<td><input type=text class= 'min' name=txtRef_Pres></td>";
echo "<td><input type=text class= 'min' name=txtRef_Serv></td>";
echo "<td><input type=text class= 'min' name=txtTiempo></td>";
echo "<td><input type=text class= 'min' name=txtUsuarios></td>";
echo "<td><input type=text class= 'min' name=txtHoraI></td>";
echo "<td><input type=text class= 'min' name=txtHoraII></td>";
echo "<td><input type=text class= 'min' name=txtReserva></td>";
echo "<td><input type=text class= 'min' name=txtPrecio></td>";
echo "<td><input type=text class= 'min' name=txtCoste></td>";
echo "<td><input type=text class= 'min' name=txtSumprecio></td>";
echo "<td><input type=text class= 'min' name=txtSumcoste></td>";
echo "<td><input type=text class= 'min' name=txtAcron></td>";
echo "<td>" . "<input type=submit name=add value=add" . " </td>";
echo "</form>";
echo "</table>";
?>
</body>
</html>
La linea 73 inicia la tabla.
He usado:
Código PHP:
Ver originalecho <table border=1 width=50%>
echo <table border=1 width=500>
echo <table border=1 width=500px>
echo <table border=1 width='500px'>
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