Foros del Web » Programando para Internet » PHP »

como hacer para traer el ultimo dsto registrado por el usuario en un txt o en label

Estas en el tema de como hacer para traer el ultimo dsto registrado por el usuario en un txt o en label en el foro de PHP en Foros del Web. hola sera k alguien me puede ayudar con esto es k lo k pasa es k necesito obtener el ultimo dato k el usuario registra ...
  #1 (permalink)  
Antiguo 25/08/2011, 10:51
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Pregunta como hacer para traer el ultimo dsto registrado por el usuario en un txt o en label

hola sera k alguien me puede ayudar con esto es k lo k pasa es k necesito obtener el ultimo dato k el usuario registra ya sea en la bd o en la interfaz el caso es k tiene k traerme el ultimo dato k se registre ose si el usuario registro
nombre apellidos
fabian lopez
k me traiga esos dos campos k fue los ultimos k registro en un campo de texto.
  #2 (permalink)  
Antiguo 25/08/2011, 10:58
Avatar de informacionsys  
Fecha de Ingreso: mayo-2011
Ubicación: Bogota D.C
Mensajes: 793
Antigüedad: 12 años, 11 meses
Puntos: 76
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

Hola compa

si la tabla tiene un campo o un id consecutivo, podrias traer el ultimo id consecutivo que obvio seria el ultimo registrado...

consulta:

Código PHP:
Ver original
  1. $query = "SELECT * FROM usuarios ORDER BY id_consecutivo DESC";

Oka
  #3 (permalink)  
Antiguo 25/08/2011, 10:59
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

por fa ayudenme e intentado con consulta mysql y con todo y nada me sirve???????????
  #4 (permalink)  
Antiguo 25/08/2011, 11:00
Avatar de informacionsys  
Fecha de Ingreso: mayo-2011
Ubicación: Bogota D.C
Mensajes: 793
Antigüedad: 12 años, 11 meses
Puntos: 76
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

muestra como tienes tu consulta estructura ? o tu codigo
  #5 (permalink)  
Antiguo 25/08/2011, 11:00
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

pero es k lo malo es k no tiene id's consecutivos.........
  #6 (permalink)  
Antiguo 25/08/2011, 11:01
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

ublic function traer_fecha($fecha)
{
$this->fecha = $fecha;

$objmysql = new sqlsito();

$this->conexion = $objmysql->conectarBD();
$this->sql = ("select fecha FROM cabecera
where Num_Doc = $this->cod");
$this->resultado = mysql_query($this->sql);

mysql_error($this->conexion);

$this->conexion = $objmysql->desconectar();

}
  #7 (permalink)  
Antiguo 25/08/2011, 11:01
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

esa es la funcion k tengo para eso???
  #8 (permalink)  
Antiguo 25/08/2011, 11:03
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

y mira en el controlador la llamo asi
$ja=$crud->traer_fecha($fecha);
echo $ja;
  #9 (permalink)  
Antiguo 25/08/2011, 11:05
Avatar de informacionsys  
Fecha de Ingreso: mayo-2011
Ubicación: Bogota D.C
Mensajes: 793
Antigüedad: 12 años, 11 meses
Puntos: 76
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

Hola compa

cuales son los campos de tu tabla, lo unico en mente es que tengas o crees un campo fecha el cual te serviria para lo que necesitas..
  #10 (permalink)  
Antiguo 25/08/2011, 11:06
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

y en la interfaz asi
<input type='text' name='fecha' value="
<?php include 'clases/CRUD_Cabecera.php';
$res = new CRUD_Cabecera();
$obj = $res->traer_fecha($fecha);
echo $obj;

pero el me vota este error <br /><b>Notice</b>: Undefined variable: jA in <b>C:\xampp\htdocs\Inventario\nuevo.php</b> on line <b>103</b><br />
  #11 (permalink)  
Antiguo 25/08/2011, 11:09
Avatar de informacionsys  
Fecha de Ingreso: mayo-2011
Ubicación: Bogota D.C
Mensajes: 793
Antigüedad: 12 años, 11 meses
Puntos: 76
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

Hola compa..

muestra que codigo tienes en el archivo nuevo.php

porque el error indica que no tienes definida una variable con el nombre de jA ....
  #12 (permalink)  
Antiguo 25/08/2011, 11:10
Avatar de CesarHC  
Fecha de Ingreso: junio-2011
Ubicación: localhost
Mensajes: 566
Antigüedad: 12 años, 10 meses
Puntos: 56
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

Dinos si el id de la tabla es autoincrementable o no.
__________________
Solo la práctica no te traicionara ¡¡¡¡¡¡

Seguir el camino tu debes PHP The Right Way.
  #13 (permalink)  
Antiguo 25/08/2011, 11:16
 
Fecha de Ingreso: agosto-2011
Mensajes: 80
Antigüedad: 12 años, 8 meses
Puntos: 0
Respuesta: como hacer para traer el ultimo dsto registrado por el usuario en un txt o

mira es te es el codigo de nuevo y no no hay un id autoincrementable
<?php

include('config.php');
if (isset($_POST['submitted'])) {
foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); }
$sql = "INSERT INTO `detalles` ( `Cabecera_Cod_Doc` , `Cabecera_Num_Doc` , `referencia_Cod_Referencia` , `Nombre_Ref` , `linea` , `fecha` , `tipodetalle`, `lote`, `cantidad`, `ubicacion`, `observacion`, `periodo` ) VALUES( 'EA' , '2' , '{$_POST['referencia_Cod_Referencia']}' , '{$_POST['Nombre_Ref']}' , '{$_POST['linea']}' , '{$_POST['fecha']}' , '{$_POST['tipodetalle']}', '{$_POST['lote']}', '{$_POST['cantidad']}', '{$_POST['ubicacion']}', '{$_POST['observacion']}', '{$_POST['periodo']}' ) ";
mysql_query($sql) or die(mysql_error());
echo "<font color=#F2F2F2>Columna creada.</font><br />";
echo "<a href='Cabecera.php'>Regrese a la lista</a>";

}
?>
<?php
if (isset($_GET['Cabecera_Cod_Doc']) ) {
if ($_POST['Cabecera_Cod_Doc']== 'ea' ) {
$jA=$_POST['tipodetalle']=='e';
} }?>
<link href="structura.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
function MesSistema(){
horasistema = new Date();
mes = horasistema.getMonth()+1;
periodo = mes;
document.detalle.periodo.value = periodo;

function submitform(){
document.forms['der'].submit();
}
}
</script>


<body onload="MesSistema()">

<div class="contenedor" >


<div class="encabezado">


</div>


<div class="barra" >


<table align="center">
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;&nb sp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp; <img src="separardor.png"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="index.php"><font color="#F2F2F2">Inicio</font></a></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp; <img src="separardor.png"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="Usuario.php"><font color="#F2F2F2">Usuario</font></a></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp; <img src="separardor.png"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="Unidades.php"><font color="#F2F2F2">Unidades</font></a></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp; <img src="separardor.png"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="Referencia.php"><font color="#F2F2F2">Referencia</font></a></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp; <img src="separardor.png"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="Cabecera.php"><font color="#F2F2F2">Movimientos</font></a></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp; <img src="separardor.png"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><a href="saldos.php"><font color="#F2F2F2">saldos</font></a></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp; <img src="separardor.png"> &nbsp;&nbsp;&nbsp;&nbsp;</td>

</tr>


</table>


</div>
<div class="centro">
<form action='' method='POST' name="detalle" >
<font color="#F2F2F2">
<table style="position:absolute;top:230px;left:350px;" >
<HR><H3>NUEVO DETALLE</H3><hr><font color="#F2F2F2">Por favor ingresar datos para registrar el nuevo detalle..........</font>
<tr>
<td><p><b><font color="#F2F2F2">o referencia_Cod_Referencia :</font></b><br /></td>
<td><select name="referencia_Cod_Referencia">
<?php
$link = mysql_connect('localhost', 'root', '');
mysql_select_db('inventario3', $link);
$query = "SELECT * FROM referencia";
$resultado = mysql_query($query);
if ($resultado)
while ($renglon = mysql_fetch_array($resultado)) {
$id = $renglon['Cod_Referencia'];
echo "<option value=".$id.">" . $id . "</option>\n";
}


mysql_close($link);
?>
</select></td></tr>
<tr>
<td><p><b><font color="#F2F2F2">o Nombre_Ref :</font></b><br /></td><td><input type='text' name='Nombre_Ref' /></td></tr>
<tr><td><p><b><font color="#F2F2F2">o linea :</font></b><br /></td><td><input type='text' name='linea'/></td></tr>
<tr><td><p><b><font color="#F2F2F2">o fecha :</font></b><br /></td><td><input type='text' name='fecha' value="
<?php include 'clases/CRUD_Cabecera.php';
$res = new CRUD_Cabecera();
$obj = $res->traer_fecha($fecha);
echo $obj;
?>"/></td></tr>
<tr><td><p><b><font color="#F2F2F2">o tipodetalle :</font></b><br /></td><td><input type='text' name='tipodetalle' value="<?php echo $jA; ?>"/></td></tr>
<tr><td><p><b><font color="#F2F2F2">o lote :</font></b><br /></td><td><input type='text' name='lote'/></td></tr>
<tr><td><p><b><font color="#F2F2F2">o cantidad :</font></b><br /></td><td><input type='text' name='cantidad'/></td></tr>
<tr><td><p><b><font color="#F2F2F2">o ubicacion :</font></b><br /></td><td><input type='text' name='ubicacion'/></td></tr>
<tr><td><p><b><font color="#F2F2F2">o observacion :</font></b><br /></td><td><input type='text' name='observacion'/></td></tr>

<tr><td><p><b><font color="#F2F2F2">o periodo :</font></b><br /></td><td><input type='text' name='periodo' readonly="true"/></td></tr>
<tr>
<td colspan="2">&emsp;</td>
</tr>
<tr><td><p><input type='reset' value='Limpiar' style="background-color: orange" style="border-color: gray"/></td>
<td><p><input type='submit' value='Crear Detalle' style="background-color: orange" style="border-color: gray"/></td><input type='hidden' value='1' name='submitted' /></td></tr>
</table>
</font>
</form>

</div>
</div>
</body>

Etiquetas: php+mysql
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 21:56.