Foros del Web » Programando para Internet » PHP »

correlativo

Estas en el tema de correlativo en el foro de PHP en Foros del Web. Hola, necesito ayuda urgente, como puedo hacer para que a medida que se pide un formulario nuevo aparezca el n° correlativo correspondiente... Form: <html> <head> ...
  #1 (permalink)  
Antiguo 16/09/2003, 17:06
 
Fecha de Ingreso: septiembre-2003
Mensajes: 7
Antigüedad: 20 años, 7 meses
Puntos: 0
correlativo

Hola, necesito ayuda urgente, como puedo hacer para que a medida que se pide un formulario nuevo aparezca el n° correlativo correspondiente...

Form:
<html>
<head>
<H3>Solicitud Mantención Preventiva</H3>
<style>
<!--
BODY{
CURSOR: url(onfire.ani);

}

-->
</style>
</head>
<body background="metal040.gif">
<script language="JavaScript">
var mensaje="Consultas y criticas a:\[email protected]";

function Toussaint(A)
{
if (document.all)
{
if (event.button == 2)
{
alert(mensaje);
return false;
}
}

if (document.layers)
document.captureEvents(Event.MOUSEDOWN);

}

document.onmousedown=Toussaint;
</script>
<FORM METHOD="POST" ACTION="Insertar.php">
<?
mysql_connect("localhost","Operador","datafull");
$sSQL="Select N_OTME From db_solicitudes";
mysql_select_db("MantEdif");
$result=mysql_query($sSQL);
?>
<table width="20%" border="2" cellspacing="1" cellpadding="1" align="left">
<tr>
<td><font size="2" face="Times">N° O.T.M.E.</font></td>
<td><input type=text value="<? echo $N_OTME ?> " name="Num_otme" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;" size="6" maxlength="7"></td>
</tr>
</table>
<table width="2%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="30%" border="2" cellspacing="1" cellpadding="1" align="center">
<tr>
<td><font size="2" face="Times">FECHA RECEPCION</font></td>
<td><input type="text" name="fecharecep" size="11" maxlength="10"></td>
</tr>
</table>
<br>
<DIV title="Datos Operarios"style="FONT-WEIGHT: bold; WIDTH: 16cm; COLOR: white; HEIGHT: 0.25cm; BACKGROUND-COLOR: steelblue"></DIV>
<br>
<table width="3%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<?
mysql_connect("localhost","Operador","datafull");
$sSQL="Select Solicitud From db_tiposolicitud";
mysql_select_db("Mantedif");
$result=mysql_query($sSQL);
?>
<table width="20%" border="2" cellspacing="1,5" cellpadding="1,5" align="left">
<tr>
<td><font size="2" face="Times">SOLICITUD</font></td>
<td><?
echo '<select name="Solicitud">';
while ($row=mysql_fetch_array($result))
{echo '<option>'.$row["Solicitud"];}
?>
</SELECT>
</tr>
</table>
<br>
<table width="3%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<br>
<table border="2" cellspacing="1" cellpadding="1" align="left">
<tr>
<td><font size="2" face="Times">DESCRIPCION</font></td>
<td><textarea cols="50" rows="3" name="descrip"></textarea></td>
</tr>
</table>
<table width="3%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<br>
<br>
<br>
<br>
<DIV title="Descripción Productos"style="FONT-WEIGHT: bold; WIDTH: 16cm; COLOR: white; HEIGHT: 0.25cm; BACKGROUND-COLOR: steelblue"></DIV>
<br>
<table width="10%" border="2" cellspacing="1,5" cellpadding="1,5" align="left">
<tr>
<td><font size="2" face="Times">SOLICITANTE</font></td>
<td><input type="text" name="solicitante" size="20" maxlength="20"></td>
</tr>
</table>
<table width="10%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<?
mysql_connect("localhost","Operador","datafull");
$sSQL="Select responsable From db_responsable";
mysql_select_db("MantEdif");
$result=mysql_query($sSQL);
?>
<table width="10%" border="2" cellspacing="1,5" cellpadding="1,5" align="left">
<tr>
<td><font size="2" face="Times">RESPONSABLE</font></td>
<td><?
echo '<select name="responsable">';
while ($row=mysql_fetch_array($result))
{echo '<option>'.$row["responsable"];}
?>
</SELECT>
</tr>
</table>
<br>
<br>
<DIV title="Repeticiones"style="FONT-WEIGHT: bold; WIDTH: 16cm; COLOR: white; HEIGHT: 0.25cm; BACKGROUND-COLOR: steelblue"></DIV>
<br>
<table width="7%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<?
mysql_connect("localhost","Operador","datafull");
$sSQL="Select sector From db_sector";
mysql_select_db("MantEdif");
$result=mysql_query($sSQL);
?>
<table width="20%" border="2" cellspacing="1" cellpadding="1" align="left">
<tr>
<td><font size="2" face="Times">SECTOR</font></td>
<td><?
echo '<select name="sector">';
while ($row=mysql_fetch_array($result))
{echo '<option>'.$row["sector"];}
?>
</SELECT>
</tr>
</table>
<table width="5%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<?
mysql_connect("localhost","Operador","datafull");
$sSQL="Select ccosto From db_solicitud";
mysql_select_db("MantEdif");
$result=mysql_query($sSQL);
?>
<table width="20%" border="2" cellspacing="1" cellpadding="1" align="center">
<tr>
<td><font size="2" face="Times">C. COSTO</font></td>
<td><?
echo '<select name="ccosto">';
while ($row=mysql_fetch_array($result))
{echo '<option>'.$row[""];}
?>
</SELECT>
</tr>
</table>
<br>
<br>
<br>
<table width="25%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table border="2" cellspacing="1" cellpadding="1" align="left">
<tr>
<td><input type="submit" value="Ingreso Datos";></td>
</tr>
</table>
</body>
</html>

Última edición por ReyMirko; 20/09/2003 a las 18:31
  #2 (permalink)  
Antiguo 16/09/2003, 18:02
 
Fecha de Ingreso: abril-2003
Mensajes: 656
Antigüedad: 21 años
Puntos: 1
En la tabla creas un campo auoincremental
tipo:

`id` int(4) NOT NULL auto_increment,

y a cada llamda del formulario haces un select y le pides la ultima
entrada, de esta manera tendras el numero de id o solucitud como
quiras llamarlo incrementado de uno

un saludo
  #3 (permalink)  
Antiguo 17/09/2003, 10:51
 
Fecha de Ingreso: septiembre-2003
Mensajes: 7
Antigüedad: 20 años, 7 meses
Puntos: 0
Gracias

Hola, gracias por tu consejo.
Pero bueno ya esta creado este campo en la tabla y esta como autoincrement, osea se va incrementando en uno...

Le hice el SELECT para el N_OTME, pero en la celda me sale el mensaje Resource id#2 que no se que onda...
  #4 (permalink)  
Antiguo 17/09/2003, 18:04
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
El código que usas no es correcto ..

Si haces:
$result=mysql_query("SELECT N_OTME ....");

DEBES de usar:
$row=mysql_fetch_array($result)

para acceder a tu campo:
echo $row['N_OTME'];

O bien usar

$tu_N_OTME=mysql_result($result,'N_OTME');
echo $tu_N_OTME;


Si tienes dudas con Mysql Y PHP .. te invito a leer las FAQ's de este foro y los tutoriales que ahí se recomiendan ...

Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.
  #5 (permalink)  
Antiguo 20/09/2003, 18:40
 
Fecha de Ingreso: septiembre-2003
Mensajes: 7
Antigüedad: 20 años, 7 meses
Puntos: 0
Gracias:

Hola Cluster y gracias mira el lunes voy a poder probar el codigo que me mandaste; ojala resulte;

Por si acaso lo que yo quiero con este Script, es que cuando yo ingreso un formulario, envio el formulario y al pedir uno nuevo me aparece el N° correlativo correspondiente al nuevo formulario, bueno gracias nuevamente...
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 17:33.