Aplicacion Web que estoy creando lo que pasa es que tengo que actualizar unos reguistro de la base de datos puedo insertarlos sin ningun problema, y tambien puedo verlos en el navegador lo que estoy haciendo es que le creo un link el nombre para que cuando le de un clic se ponga en el modo de edicion que estara en otro file.php (actualizarform.php) la actualizacion estara en el orto file.php(update.php)
Resulta que no me carga los datos del nombre que seleciono nose que estoy haciendo mal si algien me puede ayudar Por favor
Gracias
codigo que utilizo es el siguientes :
Código PHP:
<?php
trim ($texusqueda);
//comparar que este lleno los campos
if (!$texbusqueda)
{
echo "No Ha Introdusido Los Detalles de la busqueda";
}
//eliminar las barras inversas
$texbusqueda = addslashes ($texbusqueda);
$terminobusqueda = addslashes ($terminobusqueda);
// connect to db
@ $db = mysql_pconnect("localhost", "root", "****");
if (!$db)
{
echo "No se puede conectar al servidor de la base de datos - por favor inténtalo más tarde.";
exit;
}
//consulta y seleccion de DB
mysql_select_db ("cachitavacuna");
$consulta = "SELECT DISTINCT clientes.c_Id,clientes.c_Nombre,clientes.c_Apellido,clientes.c_Fecha,clientes.c_ciudad,clientes.c_Telefono,clientes.c_Direccion,
mascotas.m_Especie,mascotas.m_Nombre,mascotas.m_Raza,
vacuna.v_tipo,vacuna.v_Nombre
FROM clientes join mascotas join vacuna Where mascotas.m_Id = vacuna.m_Id
AND clientes.c_Id = mascotas.c_Id
AND clientes.c_Nombre like '".$texbusqueda."%'";
$resultado = mysql_query($consulta);
$num_resultados = mysql_num_rows($resultado);
echo "<p>Numero clientes encontrados: ".$num_resultados."</p>";
if (!$num_resultados)
{
echo "No hay Ningun registro en la Base de datos.";
}
echo "<table border = 2\n";
echo "<tr>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Nombre</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Apellido</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Telefono</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Especie</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Raza Mascota</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Nombre Mascota</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Fecha</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Tipo de vacuna</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Nombre vacuna</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Direccion</td>
<th bgcolor = \"#0066FF\"><font color=#FFFFFF>Ciudad</td>
</tr>";
for ($i=0;$i<$num_resultados;$i++)
{
$row = mysql_fetch_array($resultado);
//prosesamos los resultados
echo "<tr><th><a href='../library/actualizarform.php?Id=".$row["c_Id"]."'>".$row["c_Nombre"]."</a></td>
<th>".$row["c_Apellido"]."</td>
<th>".$row["c_Telefono"]."</td>
<th>".$row["m_Especie"]."</td>
<th>".$row["m_Raza"]."</td>
<th>".$row["m_Nombre"]."</td>
<th>".$row["c_Fecha"]."</td>
<th>".$row["v_tipo"]."</td>
<th>".$row["v_Nombre"]."</td>
<th>".$row["c_Direccion"]."</td>
<th>".$row["c_ciudad"]."</td>";
}
echo "</table>";
?>
Esto es para actualizarform.php Código PHP:
// connect to db
@ $db = mysql_pconnect("localhost", "root", "****");
if (!$db)
{
echo "No se puede conectar al servidor de la base de datos - por favor inténtalo más tarde.";
exit;
}
//consulta y seleccion de DB
mysql_select_db ("cachitavacuna");
$consulta = "SELECT DISTINCT clientes.c_Id,clientes.c_Nombre,clientes.c_Apellido,clientes.c_Fecha,clientes.c_ciudad,clientes.c_Telefono,clientes.c_Direccion,
mascotas.m_sexo,mascotas.m_Especie,mascotas.m_Nombre,mascotas.m_Raza,
vacuna.v_tipo,vacuna.v_Nombre
FROM clientes join mascotas join vacuna Where mascotas.m_Id = vacuna.m_Id
AND clientes.c_Id = mascotas.c_Id";
$resultado = mysql_query($consulta);
echo "<form id='form1' name='form1' method='post' action='update.php'>";
echo "<table border = 2\n align='center'";
$row = mysql_fetch_array($resultado);
echo "<tr><th>Clientes ID:</th><th><input type='text' name='c_Id' value=".$row["c_Id"]."/></th></tr>
<tr><th>Nombre:</th><th><input type='text' name='c_Nombre' value=".$row["c_Nombre"]."/></th></tr>
<tr><th>Apellido:</th><th><input type='text' name='c_Apellido' value=".$row["c_Apellido"]."/></th></tr>
<tr><th>Telefono:</th><th><input type='text' name='c_Telefono' value=".$row["c_Telefono"]."/></th></tr>
<tr><th>Especie:</th><th><input type='text' name='m_Especie' value=".$row["m_Especie"]."/></th></tr>
<tr><th>Raza:</th><th><input type='text' name='m_Raza' value=".$row["m_Raza"]."/></th></tr>
<tr><th>Mascota Nombre:</th><th><input type='text' name='m_Nombre' value=".$row["m_Nombre"]."/></th></tr>
<tr><th>Fecha:</th><th><input type='text' name='c_Fecha' value=".$row["c_Fecha"]."/></th></tr>
<tr><th>Tipo Vacuna:</th><th><input type='text' name='v_tipo' value=".$row["v_tipo"]."/></th></tr>
<tr><th>Vacuna Nombre:</th><th><input type='text' name='v_Nombre' value=".$row["v_Nombre"]."/></th></tr>
<tr><th>Direccion:</th><th><input type='text' name='c_Direccion' value=".$row["c_Direccion"]."/></th></tr>
<tr><th>Sexo:</th><th><input type='text' name='m_sexo' value=".$row["m_sexo"]."/></th></tr>
<tr><th>Ciudad:</th><th><input type='text' name='c_ciudad' value=".$row["c_ciudad"]."/></th></tr>
<tr><th><th><label>
<input type='submit' name='Submit' value='Actualizar'/>
</label></th>";
echo "</table>";
echo "</form>";
?>
Esto es para update.php Código PHP:
<?php
@ $db = mysql_pconnect("localhost", "root", "****");
if (!$db)
{
echo "No se puede conectar al servidor de la base de datos - por favor inténtalo más tarde.";
exit;
}
//consulta y seleccion de DB
mysql_select_db ("cachitavacuna");
$actualizar ="UPDATE clientes join mascotas join vacuna SET clientes.c_Nombre = '$c_Nombre' ,clientes.c_Apellido = '$c_Apellido' ,clientes.c_Telefono = '$c_Telefono'
,mascotas.m_Especie = '$m_Especie' ,mascotas.m_Raza = '$m_Raza' ,mascotas.m_Nombre = '$m_Nombre' ,clientes.c_Fecha = '$c_Fecha' ,vacuna.v_tipo = '$v_tipo'
,vacuna.v_Nombre ='$v_Nombre' ,clientes.c_Direccion ='$c_Direccion' ,clientes.c_ciudad ='$c_ciudad'
WHERE clientes.c_Id = mascotas.c_Id AND mascotas.m_Id = vacuna.v_Id
AND clientes.c_Id = '$c_Id'";
$resultado = mysql_query($actualizar);
if ($resultado = true)
{
echo "Gracias Registro actualizado";
}
?>