|  Respuesta: guardar en base de datos loo que insertan  
  jeje perdon no lo copie completo, mil disculpas<?php require_once('Connections/facturas.php'); ?>
 <?php
 if (!function_exists("GetSQLValueString")) {
 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
 {
 $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 variables (fac_dia, fac_mes, fac_fecha, fac_cantidad, fac_unidad, fac_desc, fac_p_unitario, fac_importe, fac_impcletra, fac_subtotal, fac_iva, fac_total) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
 GetSQLValueString($_POST['fac_dia'], "text"),
 GetSQLValueString($_POST['fac_mes'], "text"),
 GetSQLValueString($_POST['fac_fecha'], "text"),
 GetSQLValueString($_POST['fac_cantidad'], "text"),
 GetSQLValueString($_POST['fac_unidad'], "text"),
 GetSQLValueString($_POST['fac_desc'], "text"),
 GetSQLValueString($_POST['fac_p_unitario'], "text"),
 GetSQLValueString($_POST['fac_importe'], "text"),
 GetSQLValueString($_POST['fac_impcletra'], "text"),
 GetSQLValueString($_POST['fac_subtotal'], "text"),
 GetSQLValueString($_POST['fac_iva'], "text"),
 GetSQLValueString($_POST['fac_total'], "text"));
 
 mysql_select_db($database_facturas, $facturas);
 $Result1 = mysql_query($insertSQL, $facturas) or die(mysql_error());
 
 $insertGoTo = "fac_final.php";
 if (isset($_SERVER['QUERY_STRING'])) {
 $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
 $insertGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf("Location: %s", $insertGoTo));
 }
 
 $colname_fact = "-1";
 if (isset($_GET['id'])) {
 $colname_fact = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
 }
 mysql_select_db($database_facturas, $facturas);
 $query_fact = sprintf("SELECT * FROM cliente_fac WHERE id = %s", GetSQLValueString($colname_fact, "int"));
 $fact = mysql_query($query_fact, $facturas) or die(mysql_error());
 $row_fact = mysql_fetch_assoc($fact);
 $totalRows_fact = mysql_num_rows($fact);
 
 $colname_Recordset1 = "-1";
 if (isset($_GET['id'])) {
 $colname_Recordset1 = $_GET['id'];
 }
 mysql_select_db($database_facturas, $facturas);
 $query_Recordset1 = sprintf("SELECT * FROM variables WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
 $Recordset1 = mysql_query($query_Recordset1, $facturas) or die(mysql_error());
 $row_Recordset1 = mysql_fetch_assoc($Recordset1);
 $totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
 ?><!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">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Creacion de factura</title>
 
 </head>
 
 <body>
 <script language = "Javascript">
 
 function ivatotal() {
 var subtotal = event.srcElement.value
 var iva = Math.round(subtotal*.15*100)/100
 var total = Math.round(subtotal*1.15*100)/100
 document.form2.fac_iva.value=iva
 document.form2.fac_total.value=total
 }
 </script>
 <script>
 function add_row(campo)
 {
 cadena="";
 total=campo.options[campo.selectedIndex].value;
 for(i=1;i<=total;i++)
 cadena=cadena+'<input type="text" name="campo_'+i+'" /> <input type="text" name="campo1_'+i+'" /> <input type="text" name="campo2_'+i+'" /> <input type="text" name="campo3_'+i+'" /> <input type="text" name="campo4" id="campo4" value="0" onKeypress="if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" onChange="javascript:sumarImporte();"/><br>';
 document.getElementById('campos').innerHTML = cadena;
 }
 function sumarImporte() {
 var total_importe = 0;
 if (document.form2.campo4) {
 if (document.form2.campo4.length) {
 for (var i=0; i < document.form2.campo4.length; i++) {
 total_importe += parseInt(document.form2.campo4[i].value,10); //Validar si es un numero primero
 }
 } else {
 total_importe += parseInt(document.form2.campo4.value,10);
 }
 }
 document.getElementById('fac_subtotal').value = total_importe;
 }
 
 </script>
 <p>
 <div>
 </p>
 <table width="100%" height="128" border="0" bordercolor="#FFFFFF">
 <tr>
 <td colspan="3" scope="col"><form id="form1" name="form1" method="get" action="">
 <label></label>
 <table width="100%" border="0">
 <tr>
 <td width="12%" scope="col"><div align="left"><strong>N</strong><strong>o. cliente:</strong></div></td>
 <td width="29%" scope="col"><?php echo $row_fact['nom_clien']; ?></td>
 <td width="17%" scope="col"><div align="left"><strong>Nombre del cliente:</strong></div></td>
 <td width="42%" scope="col"><?php echo $row_fact['dom_clien']; ?></td>
 </tr>
 <tr>
 <td><strong>Domicilio:</strong></td>
 <td><?php echo $row_fact['dom_clien']; ?></td>
 <td><strong>Ciudad:</strong></td>
 <td><?php echo $row_fact['ciud_clien']; ?></td>
 </tr>
 <tr>
 <td><label><strong>Telefono:</strong></label></td>
 <td><label><?php echo $row_fact['tel_clien']; ?></label></td>
 <td><strong>R.F.C :</strong>
 <label></label></td>
 <td><?php echo $row_fact['rfc_clien']; ?></td>
 </tr>
 </table>
 </form></td>
 </tr>
 <tr>
 <td colspan="3"><form action="fac_final.php" method="get" name="form2">
 <table width="100%" border="0">
 <tr>
 <th width="493" scope="col"><div align="left">
 <select name="opciones" onchange="add_row(this)">
 <option value="0">0</option>
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option>
 </select>
 <em> * indica cantidad de ojetos</em></div></th>
 </tr>
 <tr>
 <td><table width="790" border="1" bordercolor="#7F9DB9">
 <tr>
 <th width="146" height="23" scope="col">cantidad</th>
 <th width="151" scope="col">unidad</th>
 <th width="155" scope="col">descripcion</th>
 <th width="155" scope="col">p unitario</th>
 <th width="143" scope="col">importe</th>
 </tr>
 </table>
 <div id="campos"></div></td>
 </tr>
 <tr>
 <td height="140"><table width="793" border="0">
 <tr>
 <th width="26" rowspan="3" scope="col"> </th>
 <th width="429" scope="col">importe con letra:
 <label></label></th>
 <th width="324" scope="col"><div align="right">
 <label></label>
 subtotal:
 <input type="text" name="fac_subtotal" id="fac_subtotal" onfocus="javascript:ivatotal()" readonly="true" />
 </div></th>
 </tr>
 <tr>
 <th width="429" scope="col"><input name="textfield4" type="text" id="textfield4" size="60"  /></th>
 <th scope="col"><label> </label>
 <div align="right">iva:
 <input type="text" name="fac_iva" id="fac_iva" readonly="true" />
 </div>
 <div align="right"></div></th>
 </tr>
 <tr>
 <th width="429" scope="col"> </th>
 <th scope="col"><label> </label>
 <div align="right">total:
 <input type="text" name="fac_total" id="fac_total" readonly="true" />
 </div></th>
 </tr>
 <tr>
 <th width="26" scope="col"> </th>
 <th width="429" scope="col"> </th>
 <th scope="col"><div align="right">
 <input name="enviar" type="submit" value="Enviar" />
 </div></th>
 </tr>
 </table>
 <div align="right"></div></td>
 </tr>
 </table>
 <label> </label>
 <p align="right">
 <label></label>
 <label></label>
 </p>
 <input type="hidden" name="MM_insert" value="form2" />
 </form></td>
 </tr>
 <tr>
 <td width="36%"><a href="busqueda_cliente.php"><img src="objetos/flecha_re.gif" width="22" height="22" border="0" /></a></td>
 <td width="21%" bordercolor="#000000"><a href="index.php">MENU PRINCIPAL</a></td>
 <td width="43%"> </td>
 </tr>
 </table>
 <p>  </p>
 <p> </p>
 
 <p> </p>
 </body>
 </html>
 <?php
 mysql_free_result($fact);
 
 mysql_free_result($Recordset1);
 ?>
     |