Create a button to register in the database each day

Asked

Viewed 26 times

1

I’m creating my table this way:

<div id="spoiler8" class="esconde">
<table class="table table-responsive" id="employee_table8"> 
<h1 style="font-size: 30px"><strong>Oratório</strong></h1>
<thead>  
<tr> 
<th>Data</th>
<th>Utente</th>
<th>Presença</th>           
<th>Motivo</th> 
<th>Colaborador</th>
<th>Tratamento</th> 
<th>Estado</th>                                 
</tr> 
<tr>
<?php 
do{
if($nomede != $produto8["DataEntrada"]){
?>  
<th style="background-color: #005dab; color: #fff; font-size: 8px;">Data: <?php echo $produto8["DataEntrada"]; ?></th>
<?php
$nomede = $produto8["DataEntrada"];
}
?>
</tr> 
</thead>
<tbody>
<tr> 
<td><?php echo $produto8["DataEntrada"]; ?></td> 
<td><?php echo $produto8["nome1"]; ?></td> 
<td><?php echo $produto8["Discricao"]; ?></td> 
<td><?php echo $produto8["Observacao4"]; ?></td>
<td><?php echo $produto8["nome"]; ?></td> 
<td><textarea rows="4" id="Notas" name="Notas" value="<?php echo $produto8["Notas"]; ?>"></textarea></td>
<td><select class="form-control" id="EstadoFinal" name="EstadoFinal"><?php echo $produto8["EstadoFinal"]; ?><option value=<?php echo $ln['Id']; ?>><?php echo $ln['Estado']; ?></option>
<?php        
$sql = "SELECT * FROM raddb.Status WHERE Id IN ('8') ORDER BY Estado ASC";
$qr = mysqli_query($conn, $sql);
while($ln = mysqli_fetch_assoc($qr)){
echo '<option value="'.$ln['Id'].'">'.$ln['Estado'].'</option>';
}
?>      
</select></td> 
</tr> 
<tr>
</tr> 
<?php } while($produto8 = $result8->fetch_assoc()); ?> 
</tbody>  
</table>
</div>

Which returns the table this way, separated by days:

inserir a descrição da imagem aqui

I want to create a button to insert into the database also per day, as shown in the image:

inserir a descrição da imagem aqui

1 answer

2


I cleaned up the PHP code only for the table to render well in HTML, but basically after the th date you need another th, this in turn should have a colspan of 6, to "occupy" all the remaining space since there are 7 columns, and to align the btn on the right you use the text-align:righ. I put a border on them th, td, just to get a better view.

Your PHP would look like this

<tr>
    <?php 
    do{
    if($nomede != $produto8["DataEntrada"]){
    ?>  
    <th style="background-color: #005dab; color: #fff; font-size: 8px;">Data: <?php echo $produto8["DataEntrada"]; ?></th>
    <th colspan="6" style="text-align: right"><button>Gravar</button></th>
    <?php
    $nomede = $produto8["DataEntrada"];
    }
    ?>
</tr>

inserir a descrição da imagem aqui

Follow the full code of the image above

th, td {
    border: 1px solid #000;
}
<div id="spoiler8" class="esconde">
    <table class="table table-responsive" id="employee_table8">
        <h1 style="font-size: 30px"><strong>Oratório</strong></h1>
        <thead>
            <tr>
                <th>Data</th>
                <th>Utente</th>
                <th>Presença</th>
                <th>Motivo</th>
                <th>Colaborador</th>
                <th>Tratamento</th>
                <th>Estado</th>
            </tr>
            <tr>
                <th style="background-color: #005dab; color: #fff; font-size: 18px;">Data: <?php echo $produto8["DataEntrada"]; ?></th>
                <th colspan="6" style="text-align: right"><button>Gravar</button></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><?php echo $produto8["DataEntrada"]; ?></td>
                <td><?php echo $produto8["nome1"]; ?></td>
                <td><?php echo $produto8["Discricao"]; ?></td>
                <td><?php echo $produto8["Observacao4"]; ?></td>
                <td><?php echo $produto8["nome"]; ?></td>
                <td>
                    <textarea rows="4" id="Notas" name="Notas" value="<?php echo $produto8["Notas"]; ?>"></textarea>
                </td>
                <td>
                    <select class="form-control" id="EstadoFinal" name="EstadoFinal">
                    <option value=<?php echo $ln['Id']; ?>><?php echo $ln['Estado']; ?></option>
                    <option value="'.$ln['Id'].'">'.$ln['Estado'].'</option></select>
                </td>
            </tr>
            <tr>
            </tr>
        </tbody>
    </table>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.