put a column in the table to mark as view

Asked

Viewed 40 times

0

I have this query and show in a table:

<form method="POST" action="">
<fieldset>
 <table cellspacing="10">
 <tr>
   <td>
	<strong>Insira data de inicio:</strong> <input type="Date" name="inicio" placeholder="PESQUISAR">
	</td>
</tr>
 </table>
</fieldset>

<fieldset>
 <table cellspacing="10">
 <tr>
   <td>
	<strong>Insira data de fim:</strong> <input type="Date" name="fim" placeholder="PESQUISAR">
	</td>
</tr>
 </table>
</fieldset>
	<input type="submit" name="pesquisa" value="ENVIAR">
</form>

<?php  

$servername = "xxx.xxx.x.xx";
$username = "xxxxx";
$password = "xxxxxxxx";
$dbname = "xxxxxxx";

$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');

if(isset($_POST['inicio']) && isset($_POST['fim']))
{

    $inicio = $_POST['inicio'];
    $fim = $_POST['fim'];
    $result_cursos = "SELECT DataRegisto,
       Dia,
       TipoRefeicao,
       Refeicao,
       Hora,
       Motivo,
       Sugestao,
       Colaborador

FROM centrodb.RegistoDiario

WHERE DataRegisto >= '$inicio' AND DataRegisto <= '$fim'";
    $resultado_cursos = mysqli_query($conn, $result_cursos);

$tabela1 .= '<div style="float: center" table align="center">';

$tabela1 .= '<table border="5">';

$tabela1 .= '<tr>';

$tabela1 .='<thead>';

$tabela1 .= '<tr>';

$tabela1 .= '<th>Data</th>';

$tabela1 .= '<th>Dia</th>';

$tabela1 .= '<th>Tipo de Refeição</th>';

$tabela1 .= '<th>Refeicao</th>';

$tabela1 .= '<th>Hora da Refeição</th>';

$tabela1 .= '<th>Motivo do incumprimento</th>';

$tabela1 .= '<th>Sugestões/Observações</th>';

$tabela1 .= '<th>Colaborador</th>';

$tabela1 .= '</tr>';

$tabela1 .='</thead>'; 

$tabela1 .='<tbody>';

    while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {

$tabela1 .= '<tr>';

$tabela1 .= '<td>'.$rows_cursos['DataRegisto'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Dia'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['TipoRefeicao'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Refeicao'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Hora'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Motivo'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Sugestao'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Colaborador'].'</td>';

$tabela1 .= '</tr>'; 
}}
$tabela1 .= '</tr>';

$tabela1 .='</tbody>'; 

$tabela1 .= '</table>';

$tabela1 .= '</div>';

echo $tabela1;

?>

I want to add a column to this table to record in the database as a view.

Like the example I put this image, have a column to mark as view:

inserir a descrição da imagem aqui

  • how so 'how view'? and in which column in the first or second? if in the second table, in which query field that returns this information?

  • Do you have an image of how you would like it to look? Your question is confused...

  • Already put, an image as an example. is how to mark as completed when consulting the information to know that we have already seen that information

1 answer

0


<?php  

$servername = "xxx.xxx.x.xx";
$username = "xxxxx";
$password = "xxxxxxxx";
$dbname = "xxxxxxx";

$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');

if(isset($_POST['inicio']) && isset($_POST['fim']))
{

    $inicio = $_POST['inicio'];
    $fim = $_POST['fim'];
    $result_cursos = "SELECT DataRegisto,
       Dia,
       TipoRefeicao,
       Refeicao,
       Hora,
       Motivo,
       Sugestao,
       Colaborador

FROM centrodb.RegistoDiario

WHERE DataRegisto >= '$inicio' AND DataRegisto <= '$fim'";
    $resultado_cursos = mysqli_query($conn, $result_cursos);

$tabela1 .= '<div style="float: center" table align="center">';

$tabela1 .= '<table border="5">';

$tabela1 .= '<tr>';

$tabela1 .='<thead>';

$tabela1 .= '<tr>';

$tabela1 .= '<th>Data</th>';

$tabela1 .= '<th>Dia</th>';

$tabela1 .= '<th>Tipo de Refeição</th>';

$tabela1 .= '<th>Refeicao</th>';

$tabela1 .= '<th>Hora da Refeição</th>';

$tabela1 .= '<th>Motivo do incumprimento</th>';

$tabela1 .= '<th>Sugestões/Observações</th>';

$tabela1 .= '<th>Colaborador</th>';

$tabela1 .= '<th>Vista</th>';

$tabela1 .= '</tr>';

$tabela1 .='</thead>'; 

$tabela1 .='<tbody>';

    while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {

$tabela1 .= '<tr>';

$tabela1 .= '<td>'.$rows_cursos['DataRegisto'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Dia'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['TipoRefeicao'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Refeicao'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Hora'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Motivo'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Sugestao'].'</td>';

$tabela1 .= '<td>'.$rows_cursos['Colaborador'].'</td>';

$tabela1 .= '<td> <input type='checkbox' name= 'Vista'> </td>';

$tabela1 .= '</tr>'; 
}}
$tabela1 .= '</tr>';

$tabela1 .='</tbody>'; 

$tabela1 .= '</table>';

$tabela1 .= '</div>';

echo $tabela1;
  • Thanks, now I just need you to do the update in the database table

Browser other questions tagged

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