Comunidad de diseño web y desarrollo en internet online

problema con el uso de botones

Citar            
MensajeEscrito el 29 Nov 2008 04:17 pm
pues tengo muchos botones y con cualquiera que presione se hacen las demas consultas, como lo puedo solucionar


<?php require_once('Connections/factura.php'); ?>
<?php require_once('Connections/detalles.php'); ?>
<?php
$fecha_actual = date("Y-m-d");
$iva = $_POST['iva'];
$calculo=(1*$iva);
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "form4")) {
$insertSQL = sprintf("INSERT INTO detalle (IDfactura, IDproducto, cantidad, descripcion, precio) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['factura'], "int"),
GetSQLValueString($_POST['IDproducto'], "int"),
GetSQLValueString($_POST['cantidad'], "int"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['precio'], "int"));

mysql_select_db($database_factura, $factura);
$Result1 = mysql_query($insertSQL, $factura) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form6")) {
$insertSQL = sprintf("INSERT INTO facturas (ID, fecha, IDcliente, importe, iva) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['numero'], "int"),
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['IDcliente'], "int"),
GetSQLValueString($_POST['importe'], "int"),
GetSQLValueString($_POST['iva'], "int"));

mysql_select_db($database_factura, $factura);
$Result1 = mysql_query($insertSQL, $factura) or die(mysql_error());

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






mysql_select_db($database_factura, $factura);
$query_detalles = "SELECT * FROM detalle WHERE detalle.IDfactura = (SELECT max(ID)+1 from facturas)";
$detalles = mysql_query($query_detalles, $factura) or die(mysql_error());
$row_detalles = mysql_fetch_assoc($detalles);
$totalRows_detalles = mysql_num_rows($detalles);

mysql_select_db($database_factura, $factura);
$query_clientes = "SELECT sum(detalle.cantidad*detalle.precio) FROM detalle WHERE detalle.IDFactura=(SELECT max(ID+1) from facturas)";
$clientes = mysql_query($query_clientes, $factura) or die(mysql_error());
$row_clientes = mysql_fetch_assoc($clientes);
$totalRows_clientes = mysql_num_rows($clientes);

mysql_select_db($database_factura, $factura);
$query_productos = "SELECT * FROM productos";
$productos = mysql_query($query_productos, $factura) or die(mysql_error());
$row_productos = mysql_fetch_assoc($productos);
$totalRows_productos = mysql_num_rows($productos);

$colname_cliente = "1";
if (isset($_POST['ID'])) {
$colname_cliente = (get_magic_quotes_gpc()) ? $_POST['ID'] : addslashes($_POST['ID']);
}
mysql_select_db($database_factura, $factura);
$query_cliente = sprintf("SELECT * FROM clientes WHERE comercial = '%s'", $colname_cliente);
$cliente = mysql_query($query_cliente, $factura) or die(mysql_error());
$row_cliente = mysql_fetch_assoc($cliente);
$totalRows_cliente = mysql_num_rows($cliente);

$colname_producto = "1";
if (isset($_POST['select'])) {
$colname_producto = (get_magic_quotes_gpc()) ? $_POST['select'] : addslashes($_POST['select']);
}
mysql_select_db($database_factura, $factura);
$query_producto = sprintf("SELECT * FROM productos WHERE descripcion = '%s'", $colname_producto);
$producto = mysql_query($query_producto, $factura) or die(mysql_error());
$row_producto = mysql_fetch_assoc($producto);
$totalRows_producto = mysql_num_rows($producto);

mysql_select_db($database_factura, $factura);
$query_Recordset1 = "SELECT detalle.IDproducto, detalle.cantidad, detalle.descripcion, detalle.precio, detalle.precio* detalle.cantidad as 'detalle.importe' FROM detalle WHERE detalle.IDfactura = (SELECT max(ID)+1 from facturas) and (detalle.cantidad > 0)";
$Recordset1 = mysql_query($query_Recordset1, $factura) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_factura, $factura);
$query_factura = "SELECT max(ID)+1 from facturas";
$factura = mysql_query($query_factura, $factura) or die(mysql_error());
$row_factura = mysql_fetch_assoc($factura);
$totalRows_factura = mysql_num_rows($factura);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 {font-family: Arial}
-->
</style>
</head>

<body>
<form name="form2" method="POST" action="<?php echo $editFormAction; ?>">
<p align="center" class="Estilo1">Sigma desarrollo empresarial y de software <img src="file:///C|/Archivos%20de%20programa/EasyPHP1-8/www/facturas/Logo%20Sigma(1).jpg" width="136" height="90"></p>
<p align="left"><span class="Estilo1">Nombre Comercial</span>
<input name="ID" type="text" class="Estilo1" id="ID" value="<?php echo $row_cliente['comercial']; ?>">
</p>
<table width="200" border="1">
<tr>
<td><span class="Estilo1">Contacto</span></td>
<td><span class="Estilo1">Raz&oacute;n</span></td>
<td><span class="Estilo1">Comercial</span></td>
<td><span class="Estilo1">RFC</span></td>
<td><span class="Estilo1">Direccion</span></td>
<td><span class="Estilo1">Ciudad</span></td>
<td><span class="Estilo1">Estado</span></td>
</tr>
<tr>
<td><span class="Estilo1"><?php echo $row_cliente['contacto']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_cliente['razon']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_cliente['comercial']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_cliente['rfc']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_cliente['direccion']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_cliente['ciudad']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_cliente['estado']; ?></span></td>
</tr>
</table>
<input name="Submit" type="submit" class="Estilo1" value="Buscar">
<p>&nbsp; </p>
<p>&nbsp;</p>
<p>
<select name="select" size="1">
<?php
do {
?>
<option value="<?php echo $row_productos['descripcion']?>"<?php if (!(strcmp($row_productos['descripcion'], $row_producto['descripcion']))) {echo "SELECTED";} ?>><?php echo $row_productos['descripcion']?></option>
<?php
} while ($row_productos = mysql_fetch_assoc($productos));
$rows = mysql_num_rows($productos);
if($rows > 0) {
mysql_data_seek($productos, 0);
$row_productos = mysql_fetch_assoc($productos);
}
?>
</select>
<input name="Submit" type="submit" class="Estilo1" value="Seleccionar Producto">
</p>
<table width="200" border="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><span class="Estilo1"><?php echo $row_producto['descripcion']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_producto['precio']; ?></span></td>
</tr>
</table>
<p>
<input type="hidden" name="MM_insert" value="form2">
</p>
<p>
<input name="factura" type="hidden" id="factura" value="<?php echo $row_factura['max(ID)+1']; ?>">
</p>
<table width="669" border="1">
<tr>
<td><span class="Estilo1">IDProducto</span></td>
<td class="Estilo1"><span class="Estilo1">Descripci&oacute;n</span></td>
<td class="Estilo1"><span class="Estilo1">Precio</span></td>
<td class="Estilo1"><span class="Estilo1">Cantidad</span></td>
</tr>
<tr>
<td><input name="IDproducto" type="text" class="Estilo1" id="IDproducto" value="<?php echo $row_producto['ID']; ?>"></td>
<td><input name="descripcion" type="text" class="Estilo1" id="descripcion" value="<?php echo $row_producto['descripcion']; ?>"></td>
<td><input name="precio" type="text" class="Estilo1" id="precio" value="<?php echo $row_producto['precio']; ?>"></td>
<td><input name="cantidad" type="text" class="Estilo1" id="cantidad"></td>
</tr>
</table>
<p>
<input name="Submit" type="submit" class="Estilo1" value="Agregar a la Factura">
</p>
<p>
<input type="hidden" name="MM_insert" value="form4">
</p>
<p>&nbsp; </p>
</form>
<form name="form3" method="post" action="">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</form>
<form name="form4" method="POST" action="<?php echo $editFormAction; ?>">
<p>&nbsp;</p>
</form>
<p align="center" class="Estilo1">Productos de la Factura </p>
<table width="741" border="1">
<tr>
<td width="164">&nbsp;</td>
<td width="162">&nbsp;</td>
<td width="144">&nbsp;</td>
<td width="130">&nbsp;</td>
<td width="107">&nbsp;</td>
</tr>
<?php do { ?>
<tr>
<td><span class="Estilo1"><?php echo $row_Recordset1['IDproducto']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_Recordset1['descripcion']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_Recordset1['cantidad']; ?></span></td>
<td><span class="Estilo1"><?php echo $row_Recordset1['precio']; ?></span></td>
<td><?php echo $row_Recordset1['detalle.importe']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<form name="form6" method="POST" action="<?php echo $editFormAction; ?>">
<p>&nbsp;</p>
<p>&lt;?php echo $row_clientes['sum(detalle.cantidad*detalle.precio)']*$calculo); ?&gt;</p>
<div align="right">
<p>
<span class="Estilo1">Fecha
<input name="fecha" type="text" id="fecha" value="<?echo $fecha_actual;?>" size="32">
</span>

<input name="Submitfac" type="submit" class="Estilo1" id="Submitfac" value="Grabar Factura">
<input name="IDcliente" type="hidden" id="IDcliente" value="<?php echo $row_cliente['ID']; ?>">
<input name="importe" type="hidden" id="importe" value="<?php echo $row_clientes['sum(detalle.cantidad*detalle.precio)']; ?>">
<input name="numero" type="hidden" id="numero" value="<?php echo $row_factura['max(ID)+1']; ?>">
</p>
<p>
<input name="textfield" type="text" class="Estilo1" value="<?php echo $row_clientes['sum(detalle.cantidad*detalle.precio)']; ?>">
</p>
<p><span class="Estilo1">Iva</span> <input name="iva" type="text" class="Estilo1" id="iva">
</p>
<p><span class="Estilo1">Total
</span>
<input name="importe" type="text" class="Estilo1" id="importe" value="<?php echo $row_clientes['sum(detalle.cantidad*detalle.precio)']*$calculo; ?>">
</p>
</div>
<input type="hidden" name="MM_insert" value="form6">
<input type="submit" name="Submit" value="Enviar">
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($detalles);

mysql_free_result($clientes);

mysql_free_result($productos);

mysql_free_result($cliente);

mysql_free_result($producto);

mysql_free_result($Recordset1);

mysql_free_result($factura);
?>

Por lista

24 de clabLevel



 

msie7
Citar            
MensajeEscrito el 29 Nov 2008 06:26 pm
bueno bella lista prepara el beso jajaja mira para q no se te ejecuten las demas sentencias deberas identoficar cada boton ejemplo

botonn uno con name -> B1 es igual en el php a -> $_POST['B1'] lo unico que debes hacer es algo como

if($_POST['B1']){
funcion o acciones para b1
}

espero que me hallas entendido saludos y espero respuestas

Por talcual

686 de clabLevel



 

Colombia

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.