Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/03/2013, 17:54
Hard_core93
 
Fecha de Ingreso: marzo-2013
Mensajes: 5
Antigüedad: 11 años, 1 mes
Puntos: 0
Pregunta Operaciones de suma y sustracción en Dreamweaver con PHP y MYSQL

Hola a todos.. este es mi primer post.. y pues fue precisamente para esto que lo cree.. pasa que estoy haciendo un proyecto en mi universidad sobre un sistema web que pueda manejar las ventas, registro de ventas e inventario de una panaderia, el sistema suena y se ve simple pero lo que me pasa es lo siguiente:

Por ahora la base de datos es de una tabla, luego implementare la del inventario, pero la que uso por ahora es una llamada Venta pan y tiene los campos:

['id_venta'], "int"),
['cantidad_concha'], "int"),
['cantidad_virote'], "int"),
['cantidad_pastel'], "int"),
['cantidad_empanada'], "int"),
['cantidad_pizza'], "int"),
['ganancia'], "text"),
['cliente'], "text"),
['fecha'], "date"));

Estos campos los uso en el registro de ventas que no es mas que un formulario para enviar estos datos, lo que quiero hacer es que cuando llene los datos campos de cantidad de cada tipo de pan.. estos tengan por asi decirlo un cierto valor para que por ejemplo cuando ponga 3 en cantidad de concha ese 3 se multiplique por el valor de la concha por ejemplo 2 pesos y en el campo ganancia esto lo vaya sumando, apareciendo 6 en el campo.. no se si me explico.. y no se realmente si esto se pueda hacer..

Espero que me puedan ayudar.. estoy usando Wampserver como servidor local y Dreamweaver CS5.. el codigo que tengo a la hora de registrar el producto es mas o menos esto:

Código:
<?php require_once('Connections/lola.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"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO ventapan (id_venta, cantidad_concha, cantidad_virote, cantidad_pastel, cantidad_empanada, cantidad_pizza, ganancia, cliente, fecha) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['id_venta'], "int"),
                       GetSQLValueString($_POST['cantidad_concha'], "int"),
                       GetSQLValueString($_POST['cantidad_virote'], "int"),
                       GetSQLValueString($_POST['cantidad_pastel'], "int"),
                       GetSQLValueString($_POST['cantidad_empanada'], "int"),
                       GetSQLValueString($_POST['cantidad_pizza'], "int"),
                       GetSQLValueString($_POST['ganancia'], "text"),
                       GetSQLValueString($_POST['cliente'], "text"),
                       GetSQLValueString($_POST['fecha'], "date"));

  mysql_select_db($database_lola, $lola);
  $Result1 = mysql_query($insertSQL, $lola) or die(mysql_error());

  $insertGoTo = "Registro e inventario.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>