giovas Posted February 15, 2009 Share Posted February 15, 2009 OK here is the thing...... I want to insert a record (works fine), and then look at the info inserted, but apparently the display page doesn't get the id, so it displays nothing. I know there is a way to get the last id inserted but I will have many users inserting records, so that won't work.... I'm using Dreamweaver to build this, cuz of course I'm new! Here is the code for the form: <form action="<?php echo $editFormAction; ?>" name="form1" id="form1" method="POST"> <table width="66%" border="0"> <tr> <td colspan="2" class="style8">Datos Generales</td> </tr> <tr> <td width="40%" align="right" class="style6">Nombre:</td> <td width="60%" class="style6"><label> <input name="Nombre" type="text" id="Nombre" size="30" maxlength="30" /> </label></td> </tr> <tr> <td align="right" class="style6">Apellido Paterno:</td> <td class="style6"><input name="ApellidoPaterno" type="text" id="ApellidoPaterno" size="30" maxlength="30" /></td> </tr> <tr> <td align="right" class="style6">Apellido Materno:</td> <td class="style6"><input name="ApellidoMaterno" type="text" id="ApellidoMaterno" size="30" maxlength="30" /></td> </tr> <tr> <td align="right" class="style6">Edad:</td> <td class="style6"><input name="Edad" type="text" id="Edad" size="3" maxlength="3" /> años <label></label></td> </tr> <tr> <td align="right" class="style6">Sexo:</td> <td class="style6"><label> <select name="Sexo" id="Sexo"> <?php do { ?><option value="<?php echo $row_Recordset1['Sexo']?>"><?php echo $row_Recordset1['Sexo']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </select> </label></td> </tr> <tr> <td align="right" class="style6">Tez:</td> <td class="style6"><label> <select name="Tez" id="Tez"> <?php do { ?> <option value="<?php echo $row_Recordset2['Tez']?>"><?php echo $row_Recordset2['Tez']?></option> <?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); $rows = mysql_num_rows($Recordset2); if($rows > 0) { mysql_data_seek($Recordset2, 0); $row_Recordset2 = mysql_fetch_assoc($Recordset2); } ?> </select> </label></td> </tr> <tr> <td align="right" class="style6">Fecha de Nacimiento:</td> <td class="style6"><label> <select name="DiaNacimiento" id="DiaNacimiento"> <?php do { ?> <option value="<?php echo $row_Recordset3['Dia']?>"><?php echo $row_Recordset3['Dia']?></option> <?php } while ($row_Recordset3 = mysql_fetch_assoc($Recordset3)); $rows = mysql_num_rows($Recordset3); if($rows > 0) { mysql_data_seek($Recordset3, 0); $row_Recordset3 = mysql_fetch_assoc($Recordset3); } ?> </select> / <select name="MesNacimiento" id="MesNacimiento"> <?php do { ?> <option value="<?php echo $row_Recordset4['Mes']?>"><?php echo $row_Recordset4['Mes']?></option> <?php } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4)); $rows = mysql_num_rows($Recordset4); if($rows > 0) { mysql_data_seek($Recordset4, 0); $row_Recordset4 = mysql_fetch_assoc($Recordset4); } ?> </select> / <select name="AnoNacimiento" id="AnoNacimiento"> <?php do { ?> <option value="<?php echo $row_Recordset5['Ano']?>"><?php echo $row_Recordset5['Ano']?></option> <?php } while ($row_Recordset5 = mysql_fetch_assoc($Recordset5)); $rows = mysql_num_rows($Recordset5); if($rows > 0) { mysql_data_seek($Recordset5, 0); $row_Recordset5 = mysql_fetch_assoc($Recordset5); } ?> </select> </label></td> </tr> <tr> <td align="right" class="style6"> </td> <td class="style6"> </td> </tr> <tr> <td colspan="2" align="center" class="style6"><label> <input type="submit" name="button" id="button" value="Agregar Paciente" /> </label></td> </tr> </table> <input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $_SESSION['MM_Username']; ?>" /> <input type="hidden" name="MM_insert" value="form1" /> </form> And here is the code for the recordset that is supposed to show the info just inserted: <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_Recordset1 = "-1"; if (isset($_GET['IdPaciente'])) { $colname_Recordset1 = $_GET['IdPaciente']; } mysql_select_db($database_diagnostico, $diagnostico); $query_Recordset1 = sprintf("SELECT * FROM pacientes WHERE IdPaciente = %s", GetSQLValueString($colname_Recordset1, "int")); $Recordset1 = mysql_query($query_Recordset1, $diagnostico) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> Link to comment https://forums.phpfreaks.com/topic/145268-get-data-after-record-insert/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.