Este es el codigo para el ingreso de los datos, lo estoy haciendo por medio de un recordset en dreamweaver.
Código 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_insert"])) && ($_POST["MM_insert"] == "form3")) {
$insertSQL = sprintf("INSERT INTO indicador (porcentaje, descripcion, cod_logro) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['porcentaje'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['cod_logro'], "int"));
mysql_select_db($database_notas, $notas);
$Result1 = mysql_query($insertSQL, $notas) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO indicador (cod_indicador, porcentaje, descripcion, cod_logro) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['cod_indicador'], "int"),
GetSQLValueString($_POST['porcentaje'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['cod_logro'], "int"));
mysql_select_db($database_notas, $notas);
$Result1 = mysql_query($insertSQL, $notas) or die(mysql_error());
echo "Registro Insertado Satisfactoriamente <br>";
}
$maxRows_registro9 = 10;
$pageNum_registro9 = 0;
if (isset($_GET['pageNum_registro9'])) {
$pageNum_registro9 = $_GET['pageNum_registro9'];
}
$startRow_registro9 = $pageNum_registro9 * $maxRows_registro9;
mysql_select_db($database_notas, $notas);
$query_registro9 = "SELECT cod_logro, porcentaje, descripcion FROM logro";
$query_limit_registro9 = sprintf("%s LIMIT %d, %d", $query_registro9, $startRow_registro9, $maxRows_registro9);
$registro9 = mysql_query($query_limit_registro9, $notas) or die(mysql_error());
$row_registro9 = mysql_fetch_assoc($registro9);
if (isset($_GET['totalRows_registro9'])) {
$totalRows_registro9 = $_GET['totalRows_registro9'];
} else {
$all_registro9 = mysql_query($query_registro9);
$totalRows_registro9 = mysql_num_rows($all_registro9);
}
$totalPages_registro9 = ceil($totalRows_registro9/$maxRows_registro9)-1;
mysql_select_db($database_notas, $notas);
$query_Recordset1 = "SELECT porcentaje, descripcion, cod_logro FROM indicador";
$Recordset1 = mysql_query($query_Recordset1, $notas) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
Este es el codigo cuando se va a modificar los registros:
Código 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 competencia SET porcentaje=%s, descripcion=%s, cod_modulo=%s WHERE cod_comp=%s",
GetSQLValueString($_POST['porcentaje'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['cod_modulo'], "int"),
GetSQLValueString($_POST['cod_comp'], "int"));
mysql_select_db($database_notas, $notas);
$Result1 = mysql_query($updateSQL, $notas) or die(mysql_error());
if(mysql_affected_rows()>0){
echo "Los Datos De La Competencia Fueron Actualizados <br>";
}else{
echo "Los Datos De La Competencia No Fueron Actualizados <br>";
}
}
$colname_Recordset1 = "-1";
if (isset($_POST['cod_comp'])) {
$colname_Recordset1 = $_POST['cod_comp'];
}
mysql_select_db($database_notas, $notas);
$query_Recordset1 = sprintf("SELECT * FROM competencia WHERE cod_comp = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $notas) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if ($totalRows_Recordset1==0){
echo "No Hay Datos Registrados Para El Código de Competencia Escogido <br>";
}else{
echo "Datos Encontrados Satisfactoriamente <br>";
}
?>