• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to accommodate the rows of my table?

#1
Help, I feel it is a fairly simple problem, but I can't find error, can you help me?

In this part where I realize the filling of the table of the bottom Confused Confused

 
Code:
<?php if( !empty($obtenOperacion)) {
            foreach($obtenOperacion as $fi) {
              if( !empty($consulta) ) {
                foreach($consulta as $fil) {
                  if($fil->operacion==$fi->operacion && $fila->cveEmpleado ==$fil->cveEmpleado AND $fil->cveEmpleado==$fil->cveEmpleado)  {
                   ?>
                   <td class="<?php echo $fil->color?>"><h4><?php echo $fil->operacion?></h4> <?php echo 'X'; ?></td>
                 <?php }#Cierra if
               elseif ($fi->operacion!=$fil->operacion) {?>
                 <td>N/A</td>
                 <?php
             }#ciella Else if
           }#Cierra consulta
         }#Cierra if que compara operación
        }#Cierra foreach fi
      }#Cierra if de obtenOperacion ?>
    </tr>


Attached Files Thumbnail(s)
   
Reply

#2
What is it that you are trying to do? Create table columns within a row? I have more questions but I will start with these two first. It also looks like you are missing the beginning <tr> for the table row.
Reply

#3
Maybe this will help:

PHP Code:
<tr>
<?
php 
    
if (!empty($obtenOperacion)) {
        foreach(
$obtenOperacion as $fi) { 
            if( !empty(
$consulta) ) {
                foreach(
$consulta as $fil) {
                    if (
$fil->operacion == $fi->operacion 
                        
&& $fila->cveEmpleado == $fil->cveEmpleado 
                        
&& $fil->cveEmpleado == $fil->cveEmpleado {
                        echo 
'<td class="' $fil->color '">' '<h4>' $fil->operacion '</h4>X</td>';
                    elseif (
$fi->operacion != $fil->operacion) {
                        echo 
'<td>N/A</td>';
                    }
                    
//what to do if $fi->operacion == $fil->operacion, but the other conditions are not valid?
                

            }
            
//what to do if $consulta is empty?
        
}
    }
    
//what to do if the $obtenOperacion is empty?
    
?>
</tr> 

There were some <?php echo statements that were not closed with ;
<?= is short hand for <?php echo
You can echo html code with php. Usually, I try to avoid it too, but within a table, your code gets really cluttered when you separate html from php.
For readability, I use spaces around the operators, like: if ($a == $b).
Reply

#4
Does it get cluttered, really?  

No.

PHP Code:
  <table>
       <tr>
           <th>header</th>
 
          <th>header2</th>
       </tr>

       <?php foreach ($vars as $var): ?>
       <tr>
           <td><?= $var ?></td>
           <td> <?php echo ( $var ) ? $var 'N/A'?> </td>
       <?php endforeach ?>

   </table> 
Reply

#5
(12-15-2016, 01:54 PM)php_rocs Wrote: What is it that you are trying to do?  Create table columns within a row?  I have more questions but I will start with these two first.  It also looks like you are missing the beginning <tr> for the table row.
It's a table first columns are personal data, second part it's about operations for employee, if I 
I want to create cells within row, If I leave it with the foreach without conditional repeats the data of all the employees, I put the condition and cause me this problem.
This information is part of the tr.
Thank u.
Reply

#6
(12-17-2016, 04:18 PM)enlivenapp Wrote: Does it get cluttered, really?  

No.

PHP Code:
  <table>
       <tr>
           <th>header</th>
 
          <th>header2</th>
       </tr>

       <?php foreach ($vars as $var): ?>
       <tr>
           <td><?= $var ?></td>
           <td> <?php echo ( $var ) ? $var 'N/A'?> </td>
       <?php endforeach ?>

   </table> 

Yeah, I have this problem but I can't solve,v I need align operations accord the list in top part
Reply

#7
(12-16-2016, 02:38 AM)Wouter60 Wrote: Maybe this will help:

PHP Code:
<tr>
<?
php 
    
if (!empty($obtenOperacion)) {
        foreach(
$obtenOperacion as $fi) { 
            if( !empty(
$consulta) ) {
                foreach(
$consulta as $fil) {
                    if (
$fil->operacion == $fi->operacion 
                        
&& $fila->cveEmpleado == $fil->cveEmpleado 
                        
&& $fil->cveEmpleado == $fil->cveEmpleado {
                        echo 
'<td class="' $fil->color '">' '<h4>' $fil->operacion '</h4>X</td>';
                    elseif (
$fi->operacion != $fil->operacion) {
                        echo 
'<td>N/A</td>';
                    }
                    
//what to do if $fi->operacion == $fil->operacion, but the other conditions are not valid?
                

            }
            
//what to do if $consulta is empty?
        
}
    }
    
//what to do if the $obtenOperacion is empty?
    
?>
</tr> 

There were some <?php echo statements that were not closed with ;
<?= is short hand for <?php echo
You can echo html code with php. Usually, I try to avoid it too, but within a table, your code gets really cluttered when you separate html from php.
For readability, I use spaces around the operators, like: if ($a == $b).
I try to avoid it too, but I can not find a way to do it, I feel that it's a little problem but I don't know and thank u  Smile
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.