Foros del Web » Programando para Internet » PHP »

Validar Porcentajes

Estas en el tema de Validar Porcentajes en el foro de PHP en Foros del Web. Hola a todos, he puesto este tema dias atras pero no tuve ninguna respuesta, espero que alguien me pueda ayudar. Estoy realizando un ingreso de ...
  #1 (permalink)  
Antiguo 17/03/2009, 21:53
 
Fecha de Ingreso: marzo-2009
Mensajes: 24
Antigüedad: 15 años, 1 mes
Puntos: 0
Validar Porcentajes

Hola a todos, he puesto este tema dias atras pero no tuve ninguna respuesta, espero que alguien me pueda ayudar.
Estoy realizando un ingreso de datos que tienen porcentajes y desearia poder validar que los porcentajes no me pasen de 100 o me diga el valor que se ha introducido hasta el momento.
El ingreso de datos es por medio de un recordset, espero alguien sepa o me de una idea para hacerlo, gracias.
  #2 (permalink)  
Antiguo 17/03/2009, 21:59
 
Fecha de Ingreso: junio-2008
Mensajes: 119
Antigüedad: 15 años, 10 meses
Puntos: 1
Respuesta: Validar Porcentajes

Pone mas datos, como algun pedazo de codigo o cual es tu problema especifico, no conozco recordset
  #3 (permalink)  
Antiguo 17/03/2009, 22:04
 
Fecha de Ingreso: marzo-2009
Mensajes: 24
Antigüedad: 15 años, 1 mes
Puntos: 0
Respuesta: Validar Porcentajes

Recordset se utiliza en dreamweaver para ingreso, busqueda o modificacion de datos y ese es el que estoy usando.


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 (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);
  if (
$Result1 mysql_query($insertSQL$notas)){; 
  echo 
"Registro Insertado Satisfactoriamente <br>";
 }else{
        echo 
"El Indicador Ya Se Encuentra Ingresado En El Sistema <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_Recordset2 "SELECT * FROM indicador";
$Recordset2 mysql_query($query_Recordset2$notas) or die(mysql_error());
$row_Recordset2 mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 mysql_num_rows($Recordset2);
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 23:08.