0
I need to declare a variable and call an object name by code and also call the type. I tried nesting the foreach
but it didn’t work. I tried to declare the variable $tipo
out of function but also did not work. If I just call it, gives an error
Undefined index: type
Follows a part of the code. This code refers to a table that displays the name, type and two buttons to delete and edit. It’s all working, I just don’t know how to call the guy to properly display the database information in the table.
echo '<table style="width:100%;border:2px solid #000000">';
//echo '<th style="border:1px solid #000000; background-color:#3b8ccc">Código</th>';
echo '<th style="border:1px solid #000000; background-color:#3b8ccc; width:55%">Local</th>';
echo '<th style="border:1px solid #000000; background-color:#3b8ccc">Tipo</th>';
echo '<th style="border:1px solid #000000; background-color:#3b8ccc">Ação</th>';
// $tipo= [];
foreach ($repositorio as $codigo => $nome['nome'])
{
echo '<tr>';
//echo '<td style="border:1px solid #000000">'.$codigo.'</td>';
echo '<td style="border:1px solid #000000">'.$nome['nome'].'</td>';
echo '<td style="border:1px solid #000000">'.$tipo['tipo'].'</td>';
echo '<td style="border:1px solid #000000">';
echo '<a href="index.php?r=a2d/excluiRepositorio&codobj='.$codigo.'"><i class="icon-remove" ></i> Excluir </a>';
echo '<i class="icon-null" ></i>'; //icon-null para espaçar os botoes
$this->widget('ext.popup.JPopupWindow');
echo '<a href="index.php?r=a2d/editarRepositorio&codobj='.$codigo.'" title="editarRepositorios" class="editarRepositorios"><i class="icon-edit" ></i> Editar </a>';
echo '<script type="text/javascript">';
echo '$(".editarRepositorios").popupWindow({
height:800,
width:1300,
top:50,
left:50
});';
echo '</script>';
echo '</td>';
echo '</tr>';
}
echo '<tr>';
echo '<td style="border:1px solid #000000">';
echo '<textarea style="height:20px; width:50%; resize:none" name="NovoRepositorio"></textarea>';
echo '</td>';
echo '<td style="border:1px solid #000000;vertical-align:text-bottom;">';
$this->widget('bootstrap.widgets.TbButton',
array(
'buttonType' => 'submit',
'type' => 'success',
'icon' => 'icon-plus-sign',
'label' => 'Adicionar',
)
);
echo '</td>';
echo '</tr>';
echo '</table>';
What exactly is/should be in the variable
$tipo
?– André Ribeiro
Could you give us an example of the structure of the variable
$repositorio
? I believe that yourforeach
should have this structureforeach ($repositorio as $codigo => $rep)
and the use ofnome
andtipo
in this way$rep['nome']
and$rep['tipo']
, but this depends on the structure of the variable$repositorio
.– Oeslei
A word. Example: In the table I have the information "Antenna" type "Laboratory". This type should be shown in a box for choice, but I will do so later. The main thing is to be able to call the information in the database.
– Thuanny Martins
public $repositorio = array();
– Thuanny Martins