Laboratorio 11

 Laboratorio 11: Trabajando con Bases de datos en PHP

TAREA: Desarrollar el código PHP para resolver los siguientes problemas, debe publicarlos en el BLOG de estudiante y pegar ekl enlace al mismo como entrega de la tarea. 

a) Crear las tablas: empleados y productos con la siguiente estructura:


b) Desarrollar el código PHP para realizar las operaciones de: 

a. Listado de Empleados, agregar, modificar y eliminar empleados de la lista 

b. Listado de productos, agregar, modificr y eliminar empleados del listado 

codigo:

producto.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CRUD con PHP usando Programación Orientada a Objetos</title>
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round|Open+S
ans">
<link rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/fontawesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.
css">
<link rel="stylesheet" href="css\custom.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
</script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
"></script>
</head>
<body>
 <div class="container">
 <div class="table-wrapper">
 <div class="table-title">
 <div class="row">
 <div class="col-sm-8"><h2>Listado de <b>PRODUCTOS</b></h2></div>
 <div class="col-sm-4">
 <a href="create.php" class="btn btn-info addnew"><i class="fa fa-plus"></i> Agregar producto</a>
 </div>
 </div>
 </div>
 <table class="table table-bordered">
 <thead>
 <tr>
 <th>descripcion</th>
 <th>unimed</th>
 <th>stock</th>
 <th>precio unitario</th>
 <th>cosuni</th>
 <th>categoria</th>
 <th>Acciones</th>
 </tr>
 </thead>
 <?php
 include ('database.php');
 $productos = new Database();
 $listado=$productos->read();
 ?>
 <tbody>
 <?php
 while ($row=mysqli_fetch_object($listado)){
 $id=$row->id;
 $descripcion=$row->descripcion;
 $unimed=$row->unimed;
 $stock=$row->stock;
 $precio=$row->preuni;
 $cosuni=$row->cosuni;
 $categoria=$row->categoria;
 ?>
 <tr>
 <td><?php echo $descripcion;?></td>
 <td><?php echo $unimed;?></td>
 <td><?php echo $stock;?></td>
 <td><?php echo $precio;?></td>
 <td><?php echo $cosuni;?></td>
 <td><?php echo $categoria;?></td>
 <td>
 <a href="update.php?id=<?php echo $id;?>"
class="edit" title="Editar" data-toggle="tooltip"><i class="materialicons">&#xE254;</i></a>
 <a href="delete.php?id=<?php echo $id;?>"
class="delete" title="Eliminar" data-toggle="tooltip"><i
class="material-icons">&#xE872;</i></a>
 </td>
 </tr>
 <?php
 }
 ?>


 </tbody>
 </table>
 <a href="..\index.php" class="btn btn-info addnew"><i class="fa fa-plus"></i> TB clientes</a>
 
 <a href="..\empleados\empleados.php" class="btn btn-info addnew"><i class="fa fa-plus"></i> TB empleados</a>
 </div>
 
 </div>


</body>
</html>

empleados.php 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CRUD con PHP usando Programación Orientada a Objetos</title>
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round|Open+S
ans">
<link rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/fontawesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.
css">
<link rel="stylesheet" href="/css/custom.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
</script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
"></script>
</head>
<body>
 <div class="container">
 <div class="table-wrapper">
 <div class="table-title">
 <div class="row">
 <div class="col-sm-8"><h2>Listado de <b>EMPLEADOS</b></h2></div>
 <div class="col-sm-4">
 <a href="create.php" class="btn btn-info addnew"><i class="fa fa-plus"></i> Agregar producto</a>
 </div>
 </div>
 </div>
 <table class="table table-bordered">
 <thead>
 <tr>
 <th>Nombres</th>
 <th>Fecha nacimiento</th>
 <th>Dirección</th>
 <th>Telefono</th>
 <th>Email</th>
 <th>Cargo</th>
 <th>Acciones</th>
 </tr>
 </thead>
 <?php
 include ('database.php');
 $empleados = new Database();
 $listado=$empleados->read();
 ?>
 <tbody>
 <?php
 while ($row=mysqli_fetch_object($listado)){
 $id=$row->id;
 $nombres=$row->nombre;
 $fechanac=$row->fechanac;
 $direccion=$row->direccion;
 $telefono=$row->telefono;
 $email=$row->email;
 $cargo=$row->cargo;
 ?>
 <tr>
 <td><?php echo $nombres;?></td>
 <td><?php echo $fechanac;?></td>
 <td><?php echo $direccion;?></td>
 <td><?php echo $telefono;?></td>
 <td><?php echo $email;?></td>
 <td><?php echo $cargo;?></td>
 <td>
 <a href="update.php?id=<?php echo $id;?>"
class="edit" title="Editar" data-toggle="tooltip"><i class="materialicons">&#xE254;</i></a>
 <a href="delete.php?id=<?php echo $id;?>"
class="delete" title="Eliminar" data-toggle="tooltip"><i
class="material-icons">&#xE872;</i></a>
 </td>
 </tr>
 <?php
 }
 ?>


 </tbody>
 </table>
 <a href="..\productos\productos.php" class="btn btn-info addnew"><i class="fa fa-plus"></i> TB productos</a>
 
 <a href="..\index.php" class="btn btn-info addnew"><i class="fa fa-plus"></i> TB clientes</a>
 </div>
 
 </div>


</body>
</html>


el codigo es lo mismo que el de cliente simplemente reemplazando nombres

empleados:







    


productos













Comentarios