Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/06/2010, 07:25
Hectorweb
 
Fecha de Ingreso: abril-2010
Mensajes: 17
Antigüedad: 14 años
Puntos: 0
Crear campos editables de una base de datos

Buenas...!
recurro a uds porq necesito ayuda.... ya no se que hacer. me dijeron que con ajax puedo resulverlo.
estoy creando un sitio donde se muestre los campos de una base de datos.
pero esos datos deben estar en una CAJA DE TEXTO (para poderlos modificar) y debe tener un boton guardar.. ya hice la base de datos. la llene aparte (ABAJO) y funciona. pero con los campos de texto estoy perdido...



Código PHP:
<!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>Mostrar Todo</title>
</head>

<body>
<form name="pepe" action="index.php" method="post">
<table border ='1' cellspacing='0'>

<?php
include ("acceso.inc.php");
$resultado mysql_query ($sql);
$campos mysql_num_fields ($resultado);
$filas mysql_num_rows ($resultado);



echo 
"<p> Cantidad de Equipos Conectados: <b> $filas </b> </p>\n";



echo 
"<tr>"//crea la fila
for ($i 0$i $campos$i++) {
    
$nombrecampo mysql_field_name ($resultado$i);
    echo 
" <th> $nombrecampo</th>";
}

echo 
"</tr>\n"//cerrar fila

// NUEVO

while ($row mysql_fetch_array($resultado)) {
$valor"j";

echo 
'<tr>';
echo 
' <td><input name="ip" type="text" id="nombre" value="<?php $valor ?>" >';

echo 
'  <td><input type="text" name="direccion" value="<?php  echo $row[Departamento]; ?>" />';
echo 
'<td width="25%">'.$row[fecha].'</td>';
echo 
'<td width="10%">'.$row['Responsable'].'</td>';
echo 
'<td width="10%">'.$row['Notas'].'</td>';
echo 
'</tr>';

}

mysql_free_result($resultado);
//fin NUEVO









mysql_close ($dp);

?>
</table>
<input type="submit" name="boton" />
</form>




<form action=" "  method="post">

<table border ='1' cellspacing='0'>
<tr>

  <td><input name="nombre" type="text" id="nombre" value="<?php $row[IP]?>" />
    <?php
include ("acceso.inc.php");
if (isset (
$_POST['submit'])) {
    if (empty (
$_POST['IP'])) {
        echo 
"<p> Introduzca una <b> IP </b>.  valida</p>";
    } else if (
strlen ($_POST['Departamento']) <3) {
        echo 
"<p> El Departamento debe tener como mínimo <b> 3 </b> caracteres</p>";
    } else {
$sql "INSERT INTO direcciones (IP, Departamento, Responsable, Notas) 
VALUES ('$_POST[IP]', '$_POST[Departamento]', '$_POST[Responsable]', '$_POST[Notas]')"
;
$resultado mysql_query ($sql);
    if (
$resultado) {
        echo 
"<p> Datos Agregados con exito</p>";
    } else { 
        echo 
"<p> Datos no agregados</p>";
    }
}
echo 
"[ <a href='javascript:history.back()' > Volver  </a>] - 
[<a href='$_SERVER[PHP_SELF]' > Introducir Nueva Fla </a>]"
;
} else {
    
$sql2="SELECT * FROM categorias";
    
$resultado2 mysql_query ($sql2);
    
$campocat "";
    while (
$row mysql_fetch_assoc ($resultado2)) {
        
$campocat .="<option value='$row [id]' > $row[categoría] </option>\n";    
}

echo <<<FORMULARIO

<form action= "
{$_SERVER['PHP_SELF']}" method= "post">
<table>
Recuerde escribir todos los datos en <b> MAYUSCULA</b> <br>
<tr> <td> IP: </td> <td> <input type= "text" name= "IP" > </td> </tr>
<tr> <td> Departamento: </td> <td> <input type= "text" name= "Departamento" > </td> </tr>
<tr> <td> Responsable: </td> <td> <input type= "text" name= "Responsable" > </td> </tr>
<tr> <td> Notas: </td> <td> <input type= "text" name= "Notas" > </td> </tr>

<tr> <td> </td> </td> <input type="submit" value="Introducir Datos" name="submit"> </td> </tr>
</table>
</form>

FORMULARIO;
mysql_close ($dp);
}
?>
  </table>
</form>
</body>
</html>

espero que me puedan ayudar..


P.D.: ( quien me ayude puedo recompenzar con hosting y base de datos por el favor)


gracias