EN LA TABLA VENDEDOR VER SUS CLICENTES, CONSULTA DESDE PHP A MYSQL
Publicado por rafael chourio (1 intervención) el 06/09/2022 06:54:06
saludo a todos, en esta ocasion nesecito toda su ayuda.
resulta que tengo una tabla la cuan le aplique el siguiente codigo:
</form>
<div class="container">
<table class="table" id= "table_id">
<thead>
<tr>
<th>Nombre</th>
<th>Local</th>
<th>Direccion</th>
<th>Departamento</th>
<th>Distrito</th>
<th>Telefono</th>
<th>Fecha</th>
<th>Vendedor</th>
<th>Imagen</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php
session_start();
$id = $_SESSION['id'];
$conexion=mysqli_connect("localhost","root","","r_user");
$SQL=mysqli_query($conexion,"SELECT cliente.id, cliente.nombre, cliente.local, cliente.direccion, cliente.departamento, cliente.distrito,
cliente.telefono, cliente.fecha, cliente.vendor, cliente.imagen FROM cliente
LEFT JOIN user ON $id = cliente.vendor");
$fila=mysqli_fetch_assoc($SQL);
if($fila['vendor'] == $id){ //admin
}
?>
<tr>
<td data-label="nombre"><?php echo $fila['nombre']; ?></td>
<td data-label="local"><?php echo $fila['local']; ?></td>
<td data-label="direccion"><?php echo $fila['direccion']; ?></td>
<td data-label="departamento"><?php echo $fila['departamento']; ?></td>
<td data-label="distrito"><?php echo $fila['distrito']; ?></td>
<td data-label="telefono"><?php echo $fila['telefono']; ?></td>
<td data-label="fecha"><?php echo $fila['fecha']; ?></td>
<td data-label="vendor"><?php echo $fila['vendor']; ?></td>
<td data-label="Imagen"><img src="../imgs/<?php echo $fila['imagen']; ?>" onerror=this.src="../imgs/noimage.jpg" width="50"
heigth="70"> <a class="btn btn-success center" href="editar_vendor2.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-edit"></i> </a></td>
<td data-label="acciones">
<a class="btn btn-primary" href="admin/index.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-edit"></i> </a>
<a class="btn btn-warning" href="editar_vendor.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-edit"></i> </a>
<a class="btn btn-danger btn-del" href="eliminar_vendor.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-trash"></i> </a>
</td>
</tr>
</table>
con este code solo me arroja un registro de la tabla cliente que esta relacionado con la tabla usuario con el rol de vendor.
ejemplo:
admin tiene 3 cliente y
roy tiene 2 cliente
pero con ese code ambos mearoja solo un solo registros.
por favor la solucion cual es:
resulta que tengo una tabla la cuan le aplique el siguiente codigo:
</form>
<div class="container">
<table class="table" id= "table_id">
<thead>
<tr>
<th>Nombre</th>
<th>Local</th>
<th>Direccion</th>
<th>Departamento</th>
<th>Distrito</th>
<th>Telefono</th>
<th>Fecha</th>
<th>Vendedor</th>
<th>Imagen</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php
session_start();
$id = $_SESSION['id'];
$conexion=mysqli_connect("localhost","root","","r_user");
$SQL=mysqli_query($conexion,"SELECT cliente.id, cliente.nombre, cliente.local, cliente.direccion, cliente.departamento, cliente.distrito,
cliente.telefono, cliente.fecha, cliente.vendor, cliente.imagen FROM cliente
LEFT JOIN user ON $id = cliente.vendor");
$fila=mysqli_fetch_assoc($SQL);
if($fila['vendor'] == $id){ //admin
}
?>
<tr>
<td data-label="nombre"><?php echo $fila['nombre']; ?></td>
<td data-label="local"><?php echo $fila['local']; ?></td>
<td data-label="direccion"><?php echo $fila['direccion']; ?></td>
<td data-label="departamento"><?php echo $fila['departamento']; ?></td>
<td data-label="distrito"><?php echo $fila['distrito']; ?></td>
<td data-label="telefono"><?php echo $fila['telefono']; ?></td>
<td data-label="fecha"><?php echo $fila['fecha']; ?></td>
<td data-label="vendor"><?php echo $fila['vendor']; ?></td>
<td data-label="Imagen"><img src="../imgs/<?php echo $fila['imagen']; ?>" onerror=this.src="../imgs/noimage.jpg" width="50"
heigth="70"> <a class="btn btn-success center" href="editar_vendor2.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-edit"></i> </a></td>
<td data-label="acciones">
<a class="btn btn-primary" href="admin/index.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-edit"></i> </a>
<a class="btn btn-warning" href="editar_vendor.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-edit"></i> </a>
<a class="btn btn-danger btn-del" href="eliminar_vendor.php?id=<?php echo $fila['id']?> ">
<i class="fa fa-trash"></i> </a>
</td>
</tr>
</table>
con este code solo me arroja un registro de la tabla cliente que esta relacionado con la tabla usuario con el rol de vendor.
ejemplo:
admin tiene 3 cliente y
roy tiene 2 cliente
pero con ese code ambos mearoja solo un solo registros.
por favor la solucion cual es:
Valora esta pregunta


0