Código PHP:
<?php require_once('../Connections/conexionseimpex.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE subcategoria SET Nombre_subcat=%s WHERE id_subcat=%s",
GetSQLValueString($_POST['Nombre_subcat'], "text"),
GetSQLValueString($_POST['id_subcat'], "int"));
mysql_select_db($database_conexionseimpex, $conexionseimpex);
$Result1 = mysql_query($updateSQL, $conexionseimpex) or die(mysql_error());
$updateGoTo = "subcategorias_lista.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$varsubcategoria_Datossubcategoria = "0";
if (isset($_GET["recordID"])) {
$varsubcategoria_Datossubcategoria = $_GET["recordID"];
}
mysql_select_db($database_conexionseimpex, $conexionseimpex);
$query_Datossubcategoria = sprintf("SELECT * FROM subcategoria WHERE subcategoria.id_subcat = %s", GetSQLValueString($varsubcategoria_Datossubcategoria, "int"));
$Datossubcategoria = mysql_query($query_Datossubcategoria, $conexionseimpex) or die(mysql_error());
$row_Datossubcategoria = mysql_fetch_assoc($Datossubcategoria);
$totalRows_Datossubcategoria = mysql_num_rows($Datossubcategoria);
mysql_select_db($database_conexionseimpex, $conexionseimpex);
$query_ConsultaCategorias = "SELECT * FROM categoria ORDER BY categoria.Nombre_cat ASC";
$ConsultaCategorias = mysql_query($query_ConsultaCategorias, $conexionseimpex) or die(mysql_error());
$row_ConsultaCategorias = mysql_fetch_assoc($ConsultaCategorias);
$totalRows_ConsultaCategorias = mysql_num_rows($ConsultaCategorias);
?>
<!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"><!-- InstanceBegin template="/Templates/BaseAdmin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Administración Seimpex C.A</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<link href="../estilo/twoColFixLtHdr.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="../../../imagen/favicon.ico"/>
</head>
<body>
<div class="container">
<div class="header"><img src="../images/logo.jpg" width="318" height="65" alt="Administracion" />
</div>
<div class="sidebar1">
<?php include("../includes/cabeceraadmin.php");
?>
<!-- end .sidebar1 --></div>
<div class="content"><!-- InstanceBeginEditable name="Contenido" -->
<script>
function subirimagen()
{
self.name = 'opener';
remote = open('gestionimagen.php', 'remote', 'width=400,height=150,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,fullscreen=no, status=yes');
remote.focus();
}
</script>
<h1>Editar Subcategoría</h1>
<p align="center"><a href="index.php" target="_self">Volver al Menú</a></p>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre:</td>
<td><span id="sprytextfield1"><input type="text" name="Nombre_subcat" value="<?php echo htmlentities($row_Datossubcategoria['Nombre_subcat'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /><span class="textfieldRequiredMsg">Necesario.</span></span>
*</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Categoria:</td>
<td><select name="id_cat">
<?php
do {
?>
<option value="<?php echo $row_ConsultaCategorias['id_cat']?>" <?php if (!(strcmp($row_ConsultaCategorias['id_cat'], htmlentities($row_Datossubcategoria['id_cat'], ENT_COMPAT, 'iso-8859-1')))) {echo "SELECTED";} ?>><?php echo $row_ConsultaCategorias['Nombre_cat']?></option>
<?php
} while ($row_ConsultaCategorias = mysql_fetch_assoc($ConsultaCategorias));
?>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Actualizar registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id_subcat" value="<?php echo $row_Datossubcategoria['id_subcat']; ?>" />
</form>
<p> </p>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
</script>
<!-- InstanceEndEditable -->
<!-- end .content --></div>
<div class="container22"></div>
<div class="footer">
<p>Administración Página Seimpex C.A</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($Datossubcategoria);
mysql_free_result($ConsultaCategorias);
?>