lunes, 17 de marzo de 2014

SEXTO CICLO

FRANCISCO MUNOZ
CATEDRATICO Ing. Juan Espinoza.

PROGRAMACION.NET
DEBER
TIPOS DE DATOS EN C#

Tipo C#Nombre पारा la plataforma .NETCon signo?Bytes utilizadosValores que soporta
boolSystem.BooleanNo1true o false (verdadero o falso en inglés)
byteSystem.ByteNo10 hasta 255
sbyteSystem.SByteSi1-128 hasta 127
shortSystem.Int16Si2-32.768 hasta 32.767
ushortSystem.Uint16No20 hasta 65535
intSystem.Int32Si4-2.147.483.648 hasta 2.147.483.647
uintSystem.Uint32No40 hasta 4.394.967.395
longSystem.Int64Si8-9.223.372.036.854.775.808 hasta 9.223.372.036.854.775.807
ulongSystem.Uint64No80 hasta 18446744073709551615
floatSystem.SingleSi4Approximadamente ±1.5E-45 hasta ±3.4E38 con 7 cifras significativas
doubleSystem.DoubleSi8Approximadamente ±5.0E-324 hasta ±1.7E308 con 7 cifras significativas
decimalSystem.DecimalSi12Approximadamente ±1.0E-28 hasta ±7.9E28 con 28 ó 29 cifras significativas
charSystem.Char
2Cualquier carácter Unicode (16 bits)

Conversiones de tipos en C#

Dado que a C# se le asignan tipos estáticos en tiempo de compilación, después de declarar una variable, no se puede volver a declarar ni tampoco utilizar para almacenar valores de otro tipo, a menos que dicho tipo pueda convertirse en el tipo de la variable. Por ejemplo, no existe conversión de un entero a una cadena arbitraria cualquiera. Por lo tanto, después de declarar i como entero, no puede asignarle la cadena "Hello", como se muestra en el código siguiente.
int i;
i = "Hello"; // Error: "Cannot implicitly convert type 'string' to 'int'"
 
Sin embargo, en ocasiones puede que sea necesario copiar un valor en un parámetro de método o variable de otro tipo. Por ejemplo, puede que tenga una variable de tipo entero que deba pasar a un método cuyo parámetro es de tipo double.  Estos tipos de operaciones se denominan conversiones de tipos. En C#, puede realizar los siguientes tipos de conversiones:
·         Conversiones implícitas: no se requiere una sintaxis especial porque la conversión se realiza con seguridad de tipos y no se perderán datos. Entre los ejemplos se incluyen las conversiones de tipos enteros de menor a mayor y las conversiones de clases derivadas en clases base.
·         Conversiones explícitas (conversiones de tipos): las conversiones explícitas requieren un operador de conversión. Las variables de origen y destino son compatibles, pero existe el riesgo de perder datos debido a que el tipo de la variable de destino es más pequeño que (o es una clase base de) la variable de origen.
·         Conversiones definidas por el usuario: las conversiones definidas por el usuario se realizan a través de métodos especiales que puede definir para habilitar las conversiones explícitas e implícitas entre tipos personalizados que no tienen una relación de clase base-clase derivada. Para obtener más información, vea Operadores de conversión (Guía de programación de C#).
·         Conversiones con clases auxiliares: para realizar conversiones entre tipos no compatibles, como los enteros y los objetos System..::.DateTime, o bien cadenas hexadecimales y matrices de bytes, puede utilizar la clase System..::.BitConverter, la clase System..::.Convert y los métodos Parse de los tipos numéricos integrados, como Int32..::.Parse..
   
Conversiones implícitas
En los tipos numéricos integrados, puede realizarse una conversión implícita cuando el valor que se va a almacenar puede ajustarse a la variable sin necesidad de truncamiento o redondeo. Por ejemplo, una variable de tipo longlong (Referencia de C#) (entero de 8 bytes) puede almacenar cualquier valor que pueda almacenar a su vez un elemento intint (Referencia de C#) (4 bytes en un equipo de 32 bits). En el ejemplo siguiente, el compilador convierte implícitamente el valor de la derecha en un tipo long antes de asignarlo a bigNum.
// Implicit conversion. num long can
// hold any value an int can hold, and more!
int num = 2147483647;
long bigNum = num;


 en C#

La instrucción if selecciona una instrucción para ejecución en base al valor de una expresión Boolean. En el ejemplo siguiente un indicador Boolean flagCheck se establece en true y, a continuación, se protege en la instrucción if. El resultado es: El indicador se pone en true. bool flagCheck = true; if (flagCheck == true) { Console.WriteLine("El flag esta true."); } else  { Console.WriteLine("El flag esta false."); }
ComentariosSi la expresión en el paréntesis se evalúa como true, a continuación se ejecuta la instrucción Console.WriteLine("El flag esta true."); . Después de ejecutar la instrucción if, el control se transfiere a la siguiente instrucción. Else no se ejecuta en este ejemplo. Si se desea ejecutar más de una instrucción, es posible ejecutar varias instrucciones en forma condicional al incluirlas en bloques mediante { }, al igual que en el ejemplo anterior. Las instrucciones que se van a ejecutar como resultado de comprobar la condición pueden ser de cualquier tipo, incluida otra instrucción if anidada dentro de la instrucción if original. En las instrucciones if anidadas, la cláusula else pertenece a la última instrucción if que no tiene una cláusula else correspondiente. Por ejemplo: if (x > 10) if (y > 20) Console.Write("Setencia_1"); else Console.Write("Sentencia_2");
En este ejemplo, se mostrará Sentencia_2 si la condición (y > 20) se evalúa como false. No obstante, si desea asociar Sentencia_2 a la condición (x >10), utilice llaves: if (x > 10) { if (y > 20) Console.Write("Sentencia_1"); } else Console.Write("Sentencia_2");
En este caso, se mostrará Sentencia_2 si la condición (x > 10) se evalúa como false. Ejemplo 1 En este ejemplo, se escribe un carácter desde el teclado y el programa comprueba si se trata de un carácter alfabético. En ese caso, comprueba si es minúscula o mayúscula. En cada caso, se muestra el mensaje apropiado. // Sentencias_if_else.cs // if-else ejemplousing System; class IfTest { static void Main() { Console.Write("Entre un caracter: "); char c = (char)Console.Read(); if (Char.IsLetter(c)) { if (Char.IsLower(c)) { Console.WriteLine("El caracter esta en minuscula."); } else { Console.WriteLine("El caracter esta en mayuscula."); } } else { Console.WriteLine("No es un caracter del alfabeto."); } } }

Resultado 2
Resultados del ejemplo Entre un caracter: 2 El caracter no es alfabético.
A continuación se ofrece otro ejemplo: Ejecución Nº 2: Entre un caracter: A El caracter está en mayúscula. Ejecución Nº 3: Entre un caracter: h El carácter esta en minúscula. También es posible extender la instrucción if de modo que puedan controlarse varias condiciones, mediante la construcción else-if siguiente: if (Condicion_1) {// Sentencia_1;} else if (Condicion_2) {// Sentencia_2;} else if (Condicion_3) {// Sentencia_3;}else{// Sentencia_n;}
Ejemplo 2Este ejemplo comprueba si el carácter especificado es una letra minúscula, mayúscula o un número. En cualquier otro caso, se tratará de un carácter no alfanumérico. El programa utiliza la anterior estructura else-if en escalera. // Sentencias_if_else2.cs // else-if using System; public class IfTest{ static void Main() { Console.Write("Entre un caracter: "); char c = (char)Console.Read(); if (Char.IsUpper(c)) { Console.WriteLine("El caracter está en mayúscula."); } else if (Char.IsLower(c)) { Console.WriteLine("El caracter está en minúscula."); } else if (Char.IsDigit(c)) { Console.WriteLine("El caracter es un numero."); } else { Console.WriteLine("El caracter no es alfanumerico."); } } }
ResultadoE
Resultados del ejemplo Entre un caracter: E El caracter esta en mayúscula
OPERADORES LOGICOS EN C#

OPERADORES ARITMÉTICOS


Binarios: los operadores binarios indican operaciones sencillas de incremento (suma o  ) y decremento (resta, división y modulo), estos son los operadores binarios:
+: representa la suma de dos o más valores o variables.
-: representa la resta de dos o más valores o variables.
*: representa la multiplicación de dos o más valores o variables.
/: representa la división de dos o más valores o variables.
%: representa el modulo (obtención del residuo de una división) de dos o más valores o variables.
Unarios: los operadores unarios representan operaciones simplificadas de incremento decremento y modificación de signos, estos son los operadores unarios:
++: Incrementa el valor de una variable en una unidad.
--: Decrementa el valor de una variable en una unidad.
-: Cambia el signo de una variable, es como multiplicar por -1.

OPERADORES RELACIONALES

  Son operadores que se encargan de unir y comparar dos o más valores, siempre se utilizan en comparaciones de parejas y están dadas por los símbolos: == : igual que != : diferente a > : mayor que < : menor que >= : mayor igual que <= : menor igual que Estos operadores se usan para comparar valores de variables por pares es decir,no se pueden comparar más de 2 valores al tiempo:
a > b > c //ERROR
(a > b) && (b > c) //BIEN

OPERADORES LÓGICOS

Son operadores de unión, también llamados compuertas lógicas, estos operadores pueden unir dos o más pares de valores comparados por medio de los operadores relaciones y están dados por estos símbolos: && : Operador AND (Y) quiere decir que todas las condiciones deben ser verdaderas para que se ejecute una acción. || : Operador OR (O) quiere decir que de todas las condiciones solo una debe ser verdadera y se asume que con eso es suficiente para hacer determinada acción. ! : Operdaro NOT (NO) quiere decir que se niega la afirmación para cambiar su valor, es decir cambia de verdadero a falso y de falso a verdadero.

SEXTO CICLO

FRANCISCO MUNOZ
CATEDRATICO: Ing Juan Espinoza.

PROGRAMACION.NET
PRACTICA
MAYOR, MENOR DE TRES NUMEROS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MAYORMENORIGUAL
{
    class Program
    {
        static void Main(string[] args)
        {
               int X,Y;  
            Console.WriteLine("Ingrese un numero");  
         int A = Convert.ToInt16(Console.ReadLine());  
            Console.WriteLine("Ingrese un numero");  
         int B = Convert.ToInt16(Console.ReadLine());  
            Console.WriteLine("Ingrese un numero");  
         int C = Convert.ToInt16(Console.ReadLine());  
          
         if (A > B && A > C)  
         {  
             X = A;  
         }  
         else  
         {  
             if (B > A && B > C )  
             {  
                 X = B;  
             }  
             else  
             {  
                 if (C > A && C > B)  
                 {  
                     X = C;  
                 }  
                 else  
                     X = C;  
             }  
         }
         if (A < B && A < C)
         {
             Y = A;
         }
         else
         {
             if (B < A && B < C)
             {
                 Y = B;
             }
             else
             {
                 if (C < A && C < B)
                 {
                     Y = C;
                 }
                 else
                 {
                     Y = C;
                 }
             }
         } 
         Console.WriteLine("el mayor es " + X + " y el menor es " + Y);  
            Console.ReadLine();  
        }  
    }  

SEXTO CICLO

FRANCISCO MUNOZ
CATEDRATICO: Ing Juan Espinoza.

PROGRAMACION.NET
PRACTICA
CARATULA

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace caratula
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\t\t\t\tNOMBRE:");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\t\t\t\tFrancisco Munoz");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\t\t\t\tCICLO:");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\t\t\t\tSexto Sistemas");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\t\t\t\tCATEDRATICO:");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\t\t\t\tIng.Juan Espinoza");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\t\t\t\tMATERIA:");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\t\t\t\tProgramacion.NET");
            Console.WriteLine("\n\t\t\t\tCICLO LECTIVO:");
            //Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\t\t\t\tFebrero 2014-Julio 2014");
            Console.ReadLine(); //pausa en pantalla
        }
    }
}

jueves, 30 de enero de 2014

DEBER 28

FRANCISCO MUNOZ
CATEDRATICO Ing. Juan Espinoza

CONEXION A BASE DE DATOS
<?php
$conexion=mysql_connect("localhost","CONEXIONBDD","admin");
if(!$conexion){
die('NO SE PUDO ESTABLECER LA CONEXION'.mysql_error());
}
else{
echo("CONEXION SATISFACTORIA");
}
mysql_select_db("BDDAGENDA", $conexion);

?>

EDITAR
<?php
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];

if($btn=="Listar"){

$sql="select * from agenda";
$cs=mysql_query($sql,$conexion);
echo"<center>
<table border='3'>
<tr>
<td>Codigo</td>
<td>Nombre</td>
<td>Apellido</td>
<td>Edad</td>
<td>Telefono</td>
<td>Direccion</td>
<td>Ciudad</td>
<td>Sexo</td>

</tr>";
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];
$var4=$resul[4];
$var5=$resul[5];
$var6=$resul[6];
$var7=$resul[7];
echo "<tr>

<td>$var</td>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>
<td>$var4</td>
<td>$var5</td>
<td>$var6</td>
<td>$var7</td>
<td><a href='actualizar.php' name='btn1'>Modificar</a></td>
</tr>";
}
ECHO "<H1><CENTER>LISTA</CENTER></H1>";
//echo '<td>'.'<a href="actualizar.php" value="Editar">'.'Modificar'.'</a>'.'</td>';
echo "</table>

</center>";

}
}
?>

ELIMINAR
<?php
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];

if($btn=="Eliminar"){

$sql="delete * from agenda";
$cs=mysql_query($sql,$conexion);
echo"<center>
<table border='3'>
<tr>
<td>Codigo</td>
<td>Nombre</td>
<td>Apellido</td>
<td>Edad</td>
<td>Telefono</td>
<td>Direccion</td>
<td>Ciudad</td>
<td>Sexo</td>

</tr>";
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];
$var4=$resul[4];
$var5=$resul[5];
$var6=$resul[6];
$var7=$resul[7];
echo "<tr>

<td>$var</td>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>
<td>$var4</td>
<td>$var5</td>
<td>$var6</td>
<td>$var7</td>
<td><a href='eliminar.php' name='btn1'>Eliminar</a></td>
</tr>";
}
ECHO "<H1><CENTER>LISTA</CENTER></H1>";
echo "</table>

</center>";

}
}
?>

martes, 21 de enero de 2014

DEBER 27

FRANCISCO MUNOZ
CATEDRATICO Ing. Juan Espinoza.

RESULTADO FINAL





PRIMERO NOS CONECTAMOS A LA BASE DE DATOS
<?php
$conexion=mysql_connect("localhost","CONEXIONBDD","admin");
if(!$conexion){
die('NO SE PUDO ESTABLECER LA CONEXION'.mysql_error());
}
else{
echo("CONEXION SATISFACTORIA");
}

AHORA SELECCIONAMOS LA BASE DE DATOS
mysql_select_db("BDDAGENDA", $conexion);
?>

DENTRO DE UN HTML REALIZAMOS LA CODIFICACION PHP
<html>
<head>
<title>DATOS</title>
</head>
<body bgcolor="celeste">
<section id="top">
<h1><CENTER>LISTAR DATOS</CENTER></h1>
</section>
<?php
$var="";
$var1="";
$var2="";
$var3="";
$var4="";
$var5="";

EXTRAEMOS LOS DATOS CON LA SENTENCIA IF Y ISSET
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];
$bus=$_POST["txtbus"];
$bus1=$_POST["txtapel"];
$bus2=$_POST["txtedad"];
$bus3=$_POST["txtdire"];

AQUI PREGUNTAMOS SI PRESIONA NOMBRE QUE REALICE LA SIGUIENTE CONSULTA



if($btn=="Nombre"){
$sql="select * from agenda where Nombre='$bus'";
$cs=mysql_query($sql,$conexion);
?>
<table width="1166" border="1" id="tab">
   <tr>
     <td width="19">Id </td>
     <td width="61">Nombre</td>
     <td width="157">Apellido</td>
     <td width="221">Edad</td>
     <td width="176">Direccion</td>
     <td width="107">Telefono</td>
   </tr>
   <?php
while($resul=mysql_fetch_array($cs)){
echo '<tr>';
echo '<td width="19">'.$resul['idagenda'].'</td>';
echo '<td width="61">'.$resul['Nombre'].'</td>';
echo '<td width="157">'.$resul['Apellido'].'</td>';
echo '<td width="221">'.$resul['Edad'].'</td>';
echo '<td width="176">'.$resul['Direccion'].'</td>';
echo '<td width="107">'.$resul['Telefono'].'</td>';
echo '</tr>';
}
}

AQUI CONSULTA PARA EL NOMBRE
if($btn=="Apellido"){

$sql="select * from agenda where Apellido='$bus1'";
$cs1=mysql_query($sql,$conexion);
?>
<table width="1166" border="1" id="tab">
   <tr>
     <td width="19">Id </td>
     <td width="61">Nombre</td>
     <td width="157">Apellido</td>
     <td width="221">Edad</td>
     <td width="176">Direccion</td>
     <td width="107">Telefono</td>
   </tr>
   <?php
while($resul=mysql_fetch_array($cs1)){
echo '<tr>';
echo '<td width="19">'.$resul['idagenda'].'</td>';
echo '<td width="61">'.$resul['Nombre'].'</td>';
echo '<td width="157">'.$resul['Apellido'].'</td>';
echo '<td width="221">'.$resul['Edad'].'</td>';
echo '<td width="176">'.$resul['Direccion'].'</td>';
echo '<td width="107">'.$resul['Telefono'].'</td>';
echo '</tr>';
}
}

AQUI CONSUTA PARA LA EDAD
if($btn=="Edad"){

$sql="select * from agenda where Edad='$bus2'";
$cs2=mysql_query($sql,$conexion);
?>
<table width="1166" border="1" id="tab">
   <tr>
     <td width="19">Id </td>
     <td width="61">Nombre</td>
     <td width="157">Apellido</td>
     <td width="221">Edad</td>
     <td width="176">Direccion</td>
     <td width="107">Telefono</td>
   </tr>
   <?php
while($resul=mysql_fetch_array($cs2)){
echo '<tr>';
echo '<td width="19">'.$resul['idagenda'].'</td>';
echo '<td width="61">'.$resul['Nombre'].'</td>';
echo '<td width="157">'.$resul['Apellido'].'</td>';
echo '<td width="221">'.$resul['Edad'].'</td>';
echo '<td width="176">'.$resul['Direccion'].'</td>';
echo '<td width="107">'.$resul['Telefono'].'</td>';
echo '</tr>';
}
}

AQUI CONSULTA PARA QUE MUESTRE DIRECCIONES IGUALES
if($btn=="Direccion"){

$sql="select * from agenda where Direccion='$bus3'";
$cs3=mysql_query($sql,$conexion);
?>
<table width="1166" border="1" id="tab">
   <tr>
     <td width="19">Id </td>
     <td width="61">Nombre</td>
     <td width="157">Apellido</td>
     <td width="221">Edad</td>
     <td width="176">Direccion</td>
     <td width="107">Telefono</td>
   </tr>
   <?php
while($resul=mysql_fetch_array($cs3)){
echo '<tr>';
echo '<td width="19">'.$resul['idagenda'].'</td>';
echo '<td width="61">'.$resul['Nombre'].'</td>';
echo '<td width="157">'.$resul['Apellido'].'</td>';
echo '<td width="221">'.$resul['Edad'].'</td>';
echo '<td width="176">'.$resul['Direccion'].'</td>';
echo '<td width="107">'.$resul['Telefono'].'</td>';
echo '</tr>';
}

}
?>

</table>
AHORA AGREGAMOS LAS CONSULTAS PARA LOS BOTONES 

NUEVO
<?php
if($btn=="Nuevo"){
$sql="select count(idagenda),Max(idagenda) from agenda";
$cs=mysql_query($sql,$conexion);
while($resul=mysql_fetch_array($cs)){
$count=$resul[0];
$max=$resul[1];
}
if($count==0){
$var="A0001";
}
else{
$var='A'.substr((substr($max,1)+10001),1);
}
}

AGREGAR
if($btn=="Agregar"){
$cod=$_POST["txtcod"];
$nom=$_POST["txtnom"];
$ape=$_POST["txtape"];
$eda=$_POST["txteda"];
$tel=$_POST["txttel"];
$dir=$_POST["cbosex"];
$sql="insert into agenda values ('$cod','$nom','$ape','$eda','$tel','$dir')";
$conexion=mysql_query($sql,$conexion);
echo "<script> alert('Se Inserto; correctamente');</script>";
}
ELIMINAR
if($btn=="Eliminar"){
$cod=$_POST["txtcod"];
$sql="delete from agenda where idagenda='$cod'";
$cs=mysql_query($sql,$conexion);
echo "<script> alert('Se elimnino correctamente');</script>";
}
}

?>
AQUI CON CODIGO HTML REALIZAMOS LOS CAMPOS PARA INGRESAR DATOS:
<form name="fe" action="" method="post">
<center>
CODIGO
<table border="2">
<tr>
<td>Codigo</td>
<td><input type="text" name="txtcod" value="<?php echo $var?>" /></td>
</tr>
NOMBRE
<tr>
<td>Nombre</td>
<td><input type="text" name="txtnom"  value="<?php echo $var1?>"/></td>
</tr>
APELLIDO
<tr>
<td>Apellido</td>
<td><input type="text" name="txtape"  value="<?php echo $var2?>"/></td>
</tr>
EDAD
<tr>
<td>Edad</td>
<td><input type="text" name="txteda"  value="<?php echo $var3?>"/></td>
</tr>
TELEFONO
<tr>
<td>Telefono;</td>
<td><input type="text" name="txttel"  value="<?php echo $var4?>"/></td>
</tr>
DIRECCION
<tr>
<td>Direccion</td>
<td><input type="text" name="cbosex"  value="<?php echo $var5?>"/></td>
</tr>

Y AQUI PONEMOS LOS BOTONES:
<tr align="center">
<td colspan="2">
NUEVO
<input type="submit" name="btn1" value="Nuevo"/>
LISTAR
<input type="submit" name="btn1" value="Listar"/>
ELIMINAR
<input type="submit" name="btn1"value="Eliminar"/>
AGREGAR
<input type="submit" name="btn1"value="Agregar"/></td></tr>
</table >

AQUI CREAMOS LOS CAMPOS Y BOTONES PARA FILTRAR CON CODIGO HTML
<table color="green" border="2">
<tr>
POR NOMBRE:
<td>Filtrar</td>
<td><input type="text" name="txtbus"/></td>
<td><input type="submit" name="btn1"  value="Nombre"  /></td>
POR APELLIDO:
<td>Filtrar</td>
<td><input type="text" name="txtapel"/></td>
<td><input type="submit" name="btn1"  value="Apellido"  /></td>
POR EDAD:
<td>Filtrar</td>
<td><input type="text" name="txtedad"/></td>
<td><input type="submit" name="btn1"  value="Edad"  /></td>
POR DIRECCION:
<td>Filtrar</td>
<td><input type="text" name="txtdire"/></td>
<td><input type="submit" name="btn1"  value="Direccion"  /></td>

</center>
<br />
<hr>
</form>
<br />


AQUI PROGRAMAMOS PARA QUE NO MUESTRE EN UNA TABLA LA LISTA CON TODOS SUS CAMPOS OSEA DESPUES DE PRESIONAR LA TECLA LISTAR.




<?php
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];

if($btn=="Listar"){
$sql="select * from agenda";
$cs=mysql_query($sql,$conexion);
echo"<center>
<table border='3'>
<tr>
<td>Codigo</td>
<td>Nombre</td>
<td>Apellido</td>
<td>Edad</td>
<td>Telefono</td>
<td>Direccion</td>
</tr>";
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];
$var4=$resul[4];
$var5=$resul[5];
echo "<tr>

<td>$var</td>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>
<td>$var4</td>
<td>$var5</td>

</tr>";
}
ECHO "<H1><CENTER>LISTA</CENTER></H1>";
echo "</table>

</center>";

}
}
?>
</body>
</html>