You are on page 1of 5

Consultar la cantidad de empleados

<?php

require "Conexiondatos.php";

$objConexion = Conectarse();

$sql = "select * from empleados where empIdentificacion='200'" ;

$sql2 = "select * from empleados";

$resultado = $objConexion->query($sql2);

$cantidadEmpleados = $resultado->num_rows;

echo "<br> Cantidad de empleados de la Base de Datos es: ".$cantidadEmpleados;

echo "<br>";

//imprimir en pantalla los datos del empleado

while ($empleado = $resultado->fetch_object())

echo "<br> Nombre Empleado: " .$empleado->empNombre;

echo "<br> Fecha Ingreso Empleado: " .$empleado->empFechaIngreso;

echo "<br> Genero Empleado: " .$empleado->empGenero;

}
Código frm Agregar Empleado

<?php

require "conexiondatos.php";

$objConexion = Conectarse();

$sql = "select idCargo, carNombre from cargos";

$resultado = $objConexion->query($sql);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Documento sin título</title>

</head>

<body>

<form id="form1" name="form1" method="post" action="">

<table width="70%" border="0" align="center">

<tr>

<td colspan="2" align="center" bgcolor="#FFCC00">AGREGAR EMPLEADOS</td>

</tr>

<tr>
<td width="34%" align="right" bgcolor="#EAEAEA">Identificacion</td>

<td width="66%"><label for="identificacion"></label>

<input name="identificacion" type="text" id="identificacion" size="40" /></td>

</tr>

<tr>

<td align="right" bgcolor="#EAEAEA">Nombre</td>

<td><label for="nombre"></label>

<input name="nombre" type="text" id="nombre" size="40" /></td>

</tr>

<tr>

<td align="right" bgcolor="#EAEAEA">Fecha Ingreso</td>

<td><label for="fechaIngreso"></label>

<input name="fechaIngreso" type="date" id="fechaIngreso" size="40" /></td>

</tr>

<tr>

<td align="right" bgcolor="#EAEAEA">Correo</td>

<td><label for="correo"></label>

<input name="correo" type="email" id="correo" size="40" /></td>

</tr>

<tr>

<td align="right" bgcolor="#EAEAEA">Genero</td>

<td><label for="genero"></label>

<select name="genero" id="genero" style="width:270px" >

<option value="0">SELECCIONE</option>

<option value="FEMENINO">FEMENINO</option>

<option value="MASCULINO">MASCULINO</option>

</select></td>
</tr>

<tr>

<td align="right" bgcolor="#EAEAEA">Cargo</td>

<td><label for="cargo"></label>

<select name="cargo" id="cargo" style="width:270px">

<option value="0">SELECCIONE</option>

<?php

while ($cargo = $resultado->fetch_object())

?>

<option value="<?php echo $cargo->idCargo?>"><?php echo $cargo-


>carNombre?></option>

<?php

?>

</select></td>

<tr>

<td colspan="2" align="center" bgcolor="#FFCC00"><input type="submit" name="button"


id="button" value="Enviar"/>

</td>

</tr>

</table>

</form>

</body>

</html>
AGREGAR DATOS A LA TABLA EMPLEADOS

<?php

require "conexiondatos.php";

extract ($_REQUEST);

$objConexion = Conectarse();

$sql = "insert into empleados (empIdentificacion, empNombre, empFechaIngreso, empCorreo,


empGenero, empCargo)

values ('$_REQUEST[identificacion]' , '$_REQUEST[nombre]', '$_REQUEST[fechaIngreso]',


'$_REQUEST[correo]'

,'$_REQUEST[genero]','$_REQUEST[cargo]')";

$resultado = $objConexion->query($sql);

if ($resultado)

echo "El empleado se ha agregado correctamente";

else

echo "Problemas al Agregar el empleado";

?>

You might also like