List Dates Online Schedules in One Table

Asked

Viewed 342 times

1

Tom with a problem here that I don’t know how to fix. I made An Agenda that returns to me the users and the calls that he would have in the week, this presented in a table equal to a weekly calendar. I’m going to put an image to better understand what it’s like today and what I want to change. Queria  todas as datas deste Usuario na mesma linha linha I wanted all the schedules of this User in the same line and in the house of the days run

<table class="table table-bordered table-striped table-white">
<thead>
<tr>
<th >Usuario</th>
<th >Segunda</th>
<th >Terça</th>
<th >Quarta</th>
<th >Quinta</th>
<th >Sexta</th>
<th >Sabado</th>
<th >Domingo</th>
</tr>
</thead>
<?

$sql ="SELECT * FROM os where status2 <> 'Fechado' AND start1      
BETWEEN '$dataRecebida' AND '$proximaData' ";
$resultado = mysql_query($sql) or die( mysql_error());
while ($linha = mysql_fetch_assoc($resultado)) {
$id1 = $linha["id1"];              
$nome = $linha["nome_cliente"];
$nome_tec = $linha["nome_tec"];
$tecnico = $linha["nome_tecnico1"];
$start1 = $linha["start1"];

$d1 = substr($start1, 0, 10 );
$t = '&nbsp;';
$d2 = substr($start1, 11, 5 );
$start = $d1.$d2;
$data1 = implode("/",array_reverse(explode("-",$d1)));
$datal = $data1.$t.$d2;

$dia = DateTime::createFromFormat('Y-m-d H:i:s', $start1);
$dia = $dia->format('D');


if($dia === 'Mon'){
$data2 = "<span class='label label-danger'>$id1</span> $datal<br>
</strong>$nome</strong> ";
}else{
$data2 = "";    
} 

if ($dia === 'Tue'){
$data3 = "<span class='label label-danger'>$id1</span> $datal<br>
<strong>$nome</strong> ";
}else{ 
$data3 = "";   
} 
if ($dia === 'Wed'){
$data4 = "<span class='label label-danger'>$id1</span> $datal<br>
<strong>$nome</strong> ";
}else{
$data4 = "";       
} 
if ($dia === 'Thu'){
$data5 = "<span class='label label-danger'>$id1</span> $datal<br>
<strong>$nome</strong> ";
}else{
$data5 = "";           
} 
if($dia === 'Fri'){
$data6 = "<span class='label label-danger'>$id1</span> $datal<br>
<strong>$nome</strong> ";
}else{
$data6 = "";           
} 
if ($dia === 'Sat'){
$data7 = "<span class='label label-danger'>$id1</span> $datal<br>
<strong>$nome</strong> ";
}else{
$data7 = "";          
}         
if ($dia === 'Sum'){
$data1 = "<span class='label label-danger'>$id1</span> $datal<br>
<strong>$nome</strong> ";
}else{
$data1 = "";          
}         
?>

<tbody>
<tr>
<td style="background-color: #CEF9FB;" ><?echo $tecnico?></td><td ><?echo $data2?>   
</td><td style="background-color: white;"><?echo $data3?></td><td><?echo $data4?> 
</td>  
<td><?echo $data5?></td><td><?echo $data6?></td><td><?echo $data7?></td><td><?echo   
$data1
?></td>
</tr>
</tbody>

<?}?>
</table>

Someone would know how to fix this

  • Fábio, note that in the image you posted, there are 2 schedules on Saturday, in this case, how should be shown? If you do everything in 1 single row, these records will have to be together in some way. How did you imagine this?

  • Ola Thomas I imagined each scheduling of these go on the same line one below the other so in the first row on Saturday I would join the Records same. Att Fabio

1 answer

0

First you’d have to understand what it would look like inside <table> , see:

<table>
  <tr>
    <th>Usuário</th>
    <th>Segunda</th>
    <th>Terça</th>
    <th>Quarta</th>
    <th>Quinta</th>
    <th>Sexta</th>
    <th>Sábado</th>
    <th>Domingo</th>
  </tr>
  <tr>
    <td>Jó Pereira</td>
    <td></td>
    <td></td>
    <td>07/01/2015 14:00<br>Cliente 1</td>
    <td></td>
    <td></td>
    <td>10/01/2015 08:00<br>Cliente 2<br></td>
    <td></td>
  </tr>
  <tr>
    <td>Jó Pereira</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td>10/01/2015 08:15<br>Cliente 3</td>
    <td></td>
  </tr>
  <tr>
    <td>Jó Pereira</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>

Note that for each new line a new one is created <tr>

After that you need to perform the query and sort it by date and time and make a loop for (I would use a for ) or while.

Browser other questions tagged

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