in advance thanks:)
I have a small question, I must take the data from an id that is in the table using phalcon with mvc.
The question is this, my table is this:
|-----------|-----------|----------|--------------|----------------|
| idusuario | nombre | apellido | clase | idpatrocinador |
|-----------|-----------|----------|--------------|----------------|
| 20065 | María | Perez | distribuidor | **20012** |
|-----------|-----------|----------|--------------|----------------|
| **20012** | Christian | Ramirez | consumidor | 20015 |
|-----------|-----------|----------|--------------|----------------|
If you notice, Christian is Maria's sponsor and what I want is to show Christian's data in the view instead of his id.
In my controller I have this:
<?php
class PruebaController extends \Phalcon\Mvc\Controller
{
public function pruebaAction()
{
}
public function indexAction()
{
//Primera consulta general
$usuarios = Usuario::find();
$this->view->usuarios = $usuarios;
//Segunda consulta para patrocinadores
$query = "SELECT * FROM usuario INNER JOIN usuario ON usuario.idusuario=usuario.idpatrocinador";
$sentencia = $this->db->prepare($query);
$sentencia->execute();
$row = $sentencia->fetch();
$this->view->row = $row;
}
}
And in the view this is my table in the view:
<table class="table table-striped table-bordered table-hover"
id="enviar_usuario">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Nombre completo</th>
<th scope="col">Clase</th>
<th scope="col">Patrocinador</th>
<th scope="col">Acción</th>
</tr>
</thead>
<tbody>
<?php
foreach($usuarios as $user)
{
?>
<tr>
<th><?php echo $user->idusuario ?></th>
<td><?php echo $user->nombre . ' ' . $user->apellido; ?></td>
<td><span class='badge badge-info'><?php echo $user->clase ?></span>";
</td>
<td> <!-- Aqui debe ir los datos del patrocinador. Su nombre completo, id y clasesph -->
</td>
<td>
<button type="button" class="btn btn-warning btn-sm" id="id_usuario" onclick="enviarid('<?php echo $user->idusuario; ?>')" ><i class="icon-pencil5 position-left"></i>
Editar</button>
</td>
</tr>
<?php
}
?>
I would greatly appreciate those who could help me