Foros del Web » Programando para Internet » PHP »

Modificar registros de la base de datos

Estas en el tema de Modificar registros de la base de datos en el foro de PHP en Foros del Web. Hola a todos, en primer lugar dar las gracias a los que me puedan ayudar.. ya que soy nuevo en esto de php.... intentaré explicarme ...
  #1 (permalink)  
Antiguo 27/04/2011, 06:40
 
Fecha de Ingreso: abril-2011
Mensajes: 39
Antigüedad: 13 años
Puntos: 1
Modificar registros de la base de datos

Hola a todos,
en primer lugar dar las gracias a los que me puedan ayudar.. ya que soy nuevo en esto de php....

intentaré explicarme lo mejor posible....

tengo una base de datos con 3 datos, EQUIPO, MODELO y SERIAL_NUMBRE en la que voy guardando los equipos...

tengo una pagina web que me muestra los 3 campos y me hace una búsqueda del equipo que ponga, y me lo muestra en una tabla en la misma página.

Como tendría que hacer para poder modificar esos valores que me muestra y una vez modificados que se guarde en la base de datos??

Gracias
  #2 (permalink)  
Antiguo 27/04/2011, 06:43
Avatar de bUllan9ebrio  
Fecha de Ingreso: enero-2011
Ubicación: Chile
Mensajes: 1.128
Antigüedad: 13 años, 2 meses
Puntos: 128
Respuesta: Modificar registros de la base de datos

Eso lo deberas realizar con un Update en MySql para poder modificar los datos, que te parece si posteas el code para poder guiarte en lo que necesitas
__________________
Si no vivimos como pensamos, pronto empezaremos a pensar como vivimos.
Más vale un Gracias sincero, que un número que aumente "popularidad" ¬¬°

Universidad de chile, campeón
  #3 (permalink)  
Antiguo 27/04/2011, 06:55
 
Fecha de Ingreso: abril-2011
Mensajes: 39
Antigüedad: 13 años
Puntos: 1
Respuesta: Modificar registros de la base de datos

<!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>Search</title>



<link rel="stylesheet" type="text/css" media="screen" title="basic" href="themes/basic/grid.css" />

<style>

html, body {

margin: 0; /* Remove body margin/padding */

padding: 0;

overflow: hidden; /* Remove scroll bars on browser window */

font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;

width: 100%;

height: 100%

}



.post {

color:black;

padding: 20px 0 0 40px;

overflow: visible; /* Remove scroll bars on browser window */



}





</style>

<script src="js/jquery.js" type="text/javascript"></script>

<script src="js/jquery.jqGrid.js" type="text/javascript"></script>

<script type="text/javascript">

var gridimgpath = 'themes/basic/images';

</script>

</head>





<body>





<div id="mainPanelArea" class="tabPanel" >




<div>
<div style="margin-left:20% ;" >

Nombre<br />

<input type="text" id="Nombre" onkeydown="doSearch(arguments[0]||event)" />

</div>


<div>

<div style="margin-left:20% ;" >
Apellido<br/>

<input type="text" id="Apellido" onkeydown="doSearch(arguments[0]||event)" />



</div>

<div>
<div style="margin-left:20% ;" >

DNI<br/>

<input type="text" id="DNI" onkeydown="doSearch(arguments[0]||event)" />



</div>


<br/>



</div>

<div style="margin-left:5% ;" >

<table id="bigset" class="scroll" cellpadding="0" cellspacing="0"></table>

<div id="pagerb" class="scroll" style="text-align:center;"></div>

<script src="search.js" type="text/javascript"> </script>

<br/>







</body>

</html>
  #4 (permalink)  
Antiguo 27/04/2011, 06:56
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 2 meses
Puntos: 288
Respuesta: Modificar registros de la base de datos

no veo en ningun lugar del code q estes usando php ni mysql
  #5 (permalink)  
Antiguo 27/04/2011, 07:02
 
Fecha de Ingreso: abril-2011
Mensajes: 39
Antigüedad: 13 años
Puntos: 1
Respuesta: Modificar registros de la base de datos

perdón, copié otra página, a ver si ahora lo hago mejor......jeje

<?php

ini_set('max_execution_time', 600);

include("dbconfig.php");

// coment the above lines if php 5

include("JSON.php");

$json = new Services_JSON();

// end comment

$examp = $_REQUEST["q"]; //query number



$page = $_REQUEST['page']; // get the requested page

$limit = $_REQUEST['rows']; // get how many rows we want to have into the grid

$sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort

$sord = $_REQUEST['sord']; // get the direction



if(!$sidx) $sidx =1;



$sidx="Name";


if(isset($_GET["Nombre"])) $Nombre = $_GET['Nombre'];

else $Nombre = "";



if(isset($_GET["Apellido"])) $Apellido = $_GET['Apellido'];

else $Apellido = "";



if(isset($_GET["DNI"])) $DNI = $_GET['DNI'];

else $DNI = "";



if(isset($_GET["Empresa"])) $Empresa = $_GET['Empresa'];

else $Empresa = "";



if(isset($_GET["Visitada"])) $Visitada = $_GET['Visitada'];

else $Visitada = "";



if(isset($_GET["Asunto"])) $Asunto = $_GET['Asunto'];

else $Asunto = "";



if(isset($_GET["Registro"])) $Registro = $_GET['Registro'];

else $Registro = "";



if(isset($_GET["Acceso"])) $acceso = $_GET['Acceso'];

else $Acceso = "";



if(isset($_GET["Devolucion"])) $acceso = $_GET['Devolucion'];

else $Devolucion = "";





// Estas son las condiciones de busqueda del campo



$where = "WHERE 1=1";

if($Nombre!='') $where.= " AND Name LIKE '%$Nombre%'";

if($Apellido!='') $where.= " AND Surname LIKE '%$Apellido%'";

if($DNI!='') $where.= " AND DNI LIKE '%$DNI%'";

if($Empresa!='') $where.= " AND Company LIKE '%$Empresa%'";

if($Visitada!='') $where.= " AND Visited LIKE '%$Visitada%'";

if($Asunto!='') $where.= " AND Purpose LIKE '%$Asunto%'";

if($Registro!='') $where.= " AND Num_Registry LIKE '%$Registro%'";

if($Acceso!='') $where.= " AND Access_Card LIKE '%$Acceso%'";

if($Devolucion!='') $where.= " AND Card_Return LIKE '%$Devolucion%'";





// connect to the database

//$db = mysql_pconnect($dbhost, $dbuser, $dbpassword)

$db = mysql_pconnect("localhost", "root", "password")

or die("Connection Error: " . mysql_error());



mysql_select_db("inventario") or die("Error conecting to db.");

$result = mysql_query("SELECT COUNT(*) AS count FROM Entry ".$where);

$row = mysql_fetch_array($result,MYSQL_ASSOC);

$count = $row['count'];



if( $count >0 ) {

$total_pages = ceil($count/$limit);

} else {

$total_pages = 0;

}

if ($page > $total_pages) $page=$total_pages;

if ($limit<0) $limit = 0;

$start = $limit*$page - $limit; // do not put $limit*($page - 1)

if ($start<0) $start = 0;





$SQL="SELECT * FROM Entry ".$where." ORDER BY ID DESC, $sidx $sord LIMIT $start , $limit";



$result = mysql_query( $SQL ) or die("No se pudo ejecutar la consulta.".mysql_error());

$responce->page = $page;

$responce->total = $total_pages;

$responce->records = $count;

$i=0;



while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {

$responce->rows[$i]['id']=$row[Name];

$responce->rows[$i]['cell']=array($row[Name],$row[Surname],$row[DNI],$row[Company],$row[Visited], $row[Purpose],$row[Num_Registry],$row[Access_Card],$row[Card_Return]);

$i++;

}

echo $json->encode($responce); // coment if php 5

//echo json_encode($responce);

mysql_close($db);



?>
  #6 (permalink)  
Antiguo 27/04/2011, 07:07
Avatar de Patriarka  
Fecha de Ingreso: enero-2011
Ubicación: Moreno, Buenos Aires, Argentina
Mensajes: 2.851
Antigüedad: 13 años, 2 meses
Puntos: 288
Respuesta: Modificar registros de la base de datos

esta bien eso te trae los registros, pero lo que nos interes es cuando los mostras
y trata de ponder el codigo necesario no todo, si no es aburrido leer todo el codigo (para mi)
Entonces mostra solo la tabla donde recorres los equipos

Etiquetas: modificar, registros
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:14.