<?php
echo $ok ;
$cn=mysql_connect("localhost" , "root" , "mysql") ;
mysql_select_db("grifo") ;
if(!$ok)
{
$rs=mysql_query("select * from cliente") ;
$text1=mysql_result($rs,0, "codcli") ;
$text2=mysql_result($rs,0, "nomcli") ;
$text3=mysql_result($rs,0, "apecli") ;
}
if($ok=="Buscar")
{$rs=mysql_query("select * from cliente where codcli ='$text1'") ;
$n=mysql_affected_rows($cn);
if($n>0)
{
$text1=mysql_result($rs,0, "codcli") ;
$text2=mysql_result($rs,0, "nomcli") ;
$text3=mysql_result($rs,0, "apecli") ;
}
else
{
$text1="" ; $text2="" ; $text3="" ;
}
}
if($ok=="Limpiar")
{
$text1="" ; $text2="" ; $text3="" ;
}
if($ok=="Agregar")
{
mysql_query("insert into cliente values('$text1' , '$text2' , '$text3') " ) ;
$text1="" ; $text2="" ; $text3="" ;
}
if($ok=="Modificar")
{
mysql_query("update cliente set nomcli= '$text2' , apecli= '$text3' where codcli = '$text1' ");
$text1="" ; $text2="" ; $text3="" ;
}
if($ok=="Eliminar")
{
mysql_query("delete from cliente where codcli= '$text1' ");
$text1="" ; $text2="" ; $text3="" ;
}
?>
