los atributos son arrays pero solo puedo ingresar un dato y no puedo pasar al siguiente indice para ingresar mas datos..
este es el codigo....
Persona.php
Código:
Mantenimiento.php<?php
class Persona{
public static $id=array();
public static $pat=array();
public static $mat=array();
public static $nom=array();
public static $edad=array();
public static $sexo=array();
}
?>
Código:
interface.php<?php require_once("persona.php");
class Mantenimiento extends Persona{
public static function agregar($newid,$newpat,$newmat,$newnom,$newedad,$newsexo){
$i=count(parent::$id);
echo $i;//siempre me devuelve 0
parent::$id[$i]=$newid;
parent::$pat[$i]=$newpat;
parent::$mat[$i]=$newmat;
parent::$nom[$i]=$newnom;
parent::$edad[$i]=$newedad;
parent::$sexo[$i]=$newsexo;
}
public static function modificar($newid,$newpat,$newmat,$newnom,$newedad,$newsexo){
for($i=0;$i<count(parent::$id);$i++){
if(parent::$id[$i]==$newid){
parent::$pat[$i]=$newpat;
parent::$mat[$i]=$newmat;
parent::$nom[$i]=$newnom;
parent::$edad[$i]=$newedad;
parent::$sexo[$i]=$newsexo;
break;
}
}
}
}
?>
Código:
<!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=iso-8859-1" />
<title>Documento sin título</title>
</head>
<?php
require_once("mantenimiento.php");//esto no es el problema cuando envio los datos del formulario no se vuelve a escribir mantenimiento.php borrando los datos que se ingresaron...?
?>
<body>
<?php
if(empty($_POST['txtid'])){
crearform("","","","","","");
}else if($_REQUEST['rbtop']=="add"){
mantenimiento::agregar($_REQUEST['txtid'],$_REQUEST['txtpat'],$_REQUEST['txtmat'],$_REQUEST['txtnom'],$_REQUEST['txtedad'],$_REQUEST['txtsexo']);
echo 'Datos Agregados';
crearform($_REQUEST['txtid'],$_REQUEST['txtpat'],$_REQUEST['txtmat'],$_REQUEST['txtnom'],$_REQUEST['txtedad'],$_REQUEST['txtsexo']);
}else if($_REQUEST['rbtop']=="del"){
}else if($_REQUEST['rbtop']=="mod"){
}else if($_REQUEST['rbtop']=="srch"){
}
function crearform($nid,$npat,$nmat,$nnom,$nedad,$nsexo){
echo '<form name="frm1" action="interface.php" method="post">
<table align="center" border="1">
<tr>
<td>ID</td>
<td><input type="text" name="txtid" value="'.$nid.'"/></td>
</tr>
<tr>
<td>Paterno</td>
<td><input type="text" name="txtpat" value="'.$npat.'"/></td>
</tr>
<tr>
<td>Materno</td>
<td><input type="text" name="txtmat" value="'.$nmat.'"/></td>
</tr>
<tr>
<td>Nombre</td>
<td><input type="text" name="txtnom" value="'.$nnom.'"/></td>
</tr>
<tr>
<td>Edad</td>
<td><input type="text" name="txtedad" value="'.$nedad.'"/></td>
</tr>
<tr>
<td>Sexo</td>
<td><input type="text" name="txtsexo" value="'.$nsexo.'"/></td>
</tr>
<tr>
<td colspan="2">
Agregar<input type="radio" name="rbtop" value="add">
Eliminar<input type="radio" name="rbtop" value="del">
Modificar<input type="radio" name="rbtop" value="mod">
Buscar<input type="radio" name="rbtop" value="srch">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="btnsend" value="Enviar"/>
</td>
</tr>
</table>
</form>';
}
?>
</body>
</html>


