How can I save a table and have the result displayed in another form?

0

I'm not that good with php and I want to understand it. How can I save a table and have the result saved in the main table? In the first image, this part of the main table when clicking Add sends another screen, at the time of entering the data I want to save them in the main table. How can I do it?

    
asked by mizrmx 22.08.2017 в 18:21
source

1 answer

0

If what you want is to obtain the data that you have entered in your database, simply make a query, store them in variables and samples where you want. An example (in this case I use PDO but the idea is the same in all cases):

$consulta = "SELECT usuario, fecha, contenido FROM tabla_usuarios WHERE usuario = 'Mayra Zurita'";

$resultado = $base -> prepare($query);
$resultado->execute(array());

//aqui haces el volcado de los datos de la consulta en variables
while($row = $resultado -> fetch(PDO::FETCH_ASSOC)){
    $usuario = $row['usuario'];
    $fecha = $row['fecha'];
    $contenido = $row['contenido'];

{

Now you simply do echo of the variables wherever you want. If you want to show it in a form you can show it by echo of the whole form or include this script in your html form. To do this simply on the page of your form you include the script

<?php include('nombre_script.php'); ?>

And you show the data using the previous variables. Anywhere you can include:

<?php echo $usuario; ?>

And the name of the user you have selected will be shown by consulting the database. If you want to include the information within a <input> you can do it like this:

<input type="text" title="Nombre de usuario" value="<?php echo $nombre; ?>" > 
    
answered by 22.08.2017 в 18:57