hola buenas días, tengo una pagina en donde reúno datos a través del SQL, los desplegó con php, con el metodo get envio informacion a otro formulario(sotfware.php) rescatado el campo id_equiop
Código:
<?php
include("data/dbapertura.php");
$_pagi_sql="select inv_equipo.id_equipo, inv_tipo_equipo.nombre_tipo_equipo, inv_equipo.ip_equipo, usuario.usuario from inv_equipo inner join usuario on inv_equipo.id_usuario=usuario.id_usuario inner join inv_tipo_equipo on inv_equipo.tipo_equipo=inv_tipo_equipo.id_tipo_equipo order by inv_equipo.tipo_equipo desc";
$_pagi_cuantos = 10;
include("paginator.inc.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></title>
<link rel="stylesheet" href="css/style.css" />
<style type="text/css">
<!-- con respecto a los link
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0000FF;
}
a:hover {
text-decoration: none;
color: #FF9834;
}
a:active {
text-decoration: none;
}
a:link {
text-decoration: none;
color: #0000FF;
}
-->
</style></head>
<body>
<div id="content">
<h1>Mantenedor TI</h1>
<?php
if (isset($_GET['sesion_finalizada']))
{
echo $_GET['sesion_finalizada']."<br>";
}
?>
<hr />
<?
echo"<form id=\"form1\" name=\"form1\" method=\"post\" action=\"software.php\">";
echo"<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
echo"<tr><thead>
<td>Id</td>
<td>IP</td>
<td>Tipo</td>
<td>Usuario</td>
<td>Acciones</td>
<td><a href=\"ingreso_equipo.php\">+</a></td>
</thead></tr>";
while($fila=mysql_fetch_array($_pagi_result))
{
/**codigo prueba**/
echo"<tr><input type=\"hidden\" name=\"id_equipo\" id=\"id_equipo\" value\"$fila[id_equipo]\" />";
echo"<td width=\"5%\">$fila[id_equipo]</td>";
echo"<td width=\"10%\">$fila[ip_equipo]</td>";
echo"<td width=\"10%\">$fila[nombre_tipo_equipo]</td>";
echo"<td width=\"10%\">$fila[usuario]</td>";
echo"<td width=\"10%\"><a href=actualizar_equipo.php?id_equipo=$fila[id_equipo]>Actualizar</a></td>";
echo"<td width=\"5%\"><a href=reporte_equipo.php?id_equipo=$fila[id_equipo]>Ver</a></td>";
echo"<td width=\"10%\"><a href=software.php?id_equipo=$fila[id_equipo]>Programas</td>";
echo"<td width=\"20%\"><a href=compint.php?id_equipo=$fila[id_equipo]>Componentes Internos</a></td>";
echo"<td width=\"10%\"><a href=perisfericos.php?id_equipo=$fila[id_equipo]>Perisferico</a></td>";
echo"</tr>";
}
echo"<p>$_pagi_navegacion</p>";
echo"</table>";
echo"</form>";
?>
</div>
en software.php hago otro query a través de campo id_equipo en dondes rescado la informacion de los sofware del equipo y los desplego en una tabla en donde tambien los elimino e ingreso. El problema es si ingreso o elimino los datos desparecen de la tabla
Código:
<?
include("data/dbapertura.php");
session_start();
$id_equipo=$_GET['id_equipo'];
$sql=mysql_query("select inv_programas.id_equipo, inv_programas.id_programa, inv_list_programa.nombre_list_programa ,inv_tipo_programa.nombre_tipo_prog from inv_programas inner join inv_tipo_programa on inv_programas.id_tipo_prog=inv_tipo_programa.id_tipo_prog inner join inv_list_programa on inv_programas.id_list_programa=inv_list_programa.id_list_programa where inv_programas.id_equipo=$id_equipo order by inv_list_programa.nombre_list_programa");
if(isset($_GET["id_programa"]))
{
$id_programa=$_GET["id_programa"];
$sql2=mysql_query("select count(*) as resultado from inv_programas where id_programa=$id_programa");
while($registro=mysql_fetch_array($sql2))
{
if($registro['resultado']==1)
{
mysql_query("delete from inv_programas where id_programa=$id_programa");
header("location:software.php");
}
else
{
echo"Eliminación de registro fallida ";
}
}
}
/************************************Funcion Gerera programa jquery************************************************************/
function generaProgramas()
{
$consulta=mysql_query("SELECT id_tipo_prog, nombre_tipo_prog FROM inv_tipo_programa");
echo "<select name='tipo_prog' id='tipo_prog' onChange='cargaContenido(this.id)'>";
echo "<option value='0'>Elige</option>";
while($registro=mysql_fetch_row($consulta))
{
echo "<option value='".$registro[0]."'>".$registro[1]."</option>";
}
echo "</select>";
}
/************************************Guardar Software************************************************************/
if (isset($_POST["btnguardar"]))
{
while($fila=mysql_fetch_array($sql))
{
if ($fila[resultado]==0)
{
mysql_query("insert into inv_programas(id_programa, id_equipo, nombre_programa, id_tipo_prog) values('$_POST[id_programa]','$_POST[equipo]','$_POST[nombre_programa]', '$_POST[tipo_prog]')") OR die("Error". mysql_error());
header("location: software.php?proceso=¡El registro a sido guardado en la base de datos!");
}
else
{
header("location: software.php?proceso=¡El registro ya EXISTE, favor intentar de nuevo!");
}
}
}
?>
<!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>o</title>
<link rel="stylesheet" href="css/style.css" >
<script type="text/javascript" src="js/select_dependientes.js"></script>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<style type="text/css">
<!--
a:hover {
color: #FF9834;
text-decoration: none;
}
a:link {
color: #0000FF;
text-decoration: none;
}
a:visited {
color: #0000FF;
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style></head>
<body>
<div id="content">
<h1> Software Instalados por equipos </h1>
<hr />
<?
echo"<form id=\"form1\" name=\"form1\" method=\"post\" action=\"software.php\">";
echo"<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
echo"<tr><thead>
<td>Nombre Software</td>
<td>Tipo software</td>
<td>Acciones    <a href=\"ingreso_software.php?$id_equipo\">+</a></td>
</thead></tr>";
while($fila=mysql_fetch_array($sql))
{
echo"<tr>";
echo"<td width=\"250\">".$fila["nombre_list_programa"]. "</td>";
echo"<td width=\"30\">".$fila["nombre_tipo_prog"]."</td>";
echo"<td width=\"50\"><a href=actualizar_programa.php?id_programa=$fila[id_programa]><input type=\"hidden\" name=\"hiddenprog\" value=\"$fila[id_programa]\"/>Actualizar</a></td>";
echo"<td width=\"50\"><a href=software.php?id_programa=$fila[id_programa]>Eliminar</a></td>";
echo"</tr>";
}
echo"</table>";
echo"</form>";
?>
<form action="ingreso_software.php" method="POST" name="form2" id="form2">
<table cellpadding="1" cellspacing="0" width="100%">
<tr>
<? while ($fila=mysql_fetch_array($sql1)) {?>
<td style="width: 54%">ID</td>
<td width="60%"><label>
<input name="id_programa" type="text" value="<? echo "$fila[resultado]"?>"/>
</label></td>
<? } ?>
</tr>
<?php if(isset($_GET['proceso_ingreso'])=="") { ?>
<tr>
<td style="width: 54%">Computador</td>
<td><label>
<?php
$sql3=mysql_query("select * from inv_equipo where id_equipo=$id_equipo");
echo"<select name=\"equipo\" >";
while($fila3=mysql_fetch_array($sql3))
{
echo"<option color=\"green\" value=\"$fila3[id_equipo]\">".$fila3["nombre_equipo"]."</option>";
}
echo"</select>";
?>
</label></td>
</tr>
<? } ?>
<tr>
<td style="width: 54%">Tipo de Sotfware</td>
<td><label><?php generaProgramas(); ?>
</label></td>
</tr>
<tr>
<td style="width: 54%">Nombre Software </td>
<td><label>
<select disabled="disabled" name="nombre_programa" id="nombre_programa">
<option value="0">Selecciona opción...</option>
</select>
</label></td>
</tr>
<tr>
<td style="width: 54%"><input name="btnguardar" type="submit" id="btnguardar" value="Guardar" />
<input type="reset" name="Submit2" value="Restablecer" />
<input name="btnfinalizar" type="submit" value="Finalizar">
<td><?php
if (isset($_GET['proceso']))
{
echo $_GET['proceso']."<br>";
}
if (isset($_GET['proceso_ingreso']))
{
echo $_GET['proceso_ingreso']."<br>";
}
?></td>
</tr>
</table>
</form>
</div>
</body>
</html>