Código:
<script languaje="javascript"> function fact() { document.forma.action="factrad.php"; document.forma.method="POST"; document.forma.submit(); } </script> <SCRIPT TYPE="text/javascript"> function submitenter(myfield,e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { myfield.form.submit(); return false; } else return true; } </SCRIPT> <?php $nomb3=$dato2; $tiempo= time(); $hora=date("h:i A",$tiempo); $fecha=date("d/m/Y"); echo "<h6>HOLA $nomb3 QUE OPERACION DESEAS REALIZAR <p align=right> fecha:$fecha hora:$hora</h6>"; $conn =mysql_connect("localhost","root",""); mysql_select_db("fact",$conn); $query="select * from factrad where estatus='orden'"; $res=mysql_query($query,$conn); if(mysql_num_rows($res)!=0) { echo "<html>"; echo "<title></title>"; echo "<head><h2><center> LISTA DE FACTURAS EN ESTATUS ORDEN</center></h2>"; echo "</head>"; ?> <body onLoad="this.document.forma.num.focus();"> <?php // echo "<center><img src=logo.jpg height=150 width=120></center>"; echo "<input type=hidden name=dato2 value='$nomb3' style=width:265px; height:30px ></center>"; echo "<pre>"; //echo "<br>"; echo "<form name='forma' id='forma'>"; $impf="IMPRIMIR FACTURAS"; $valor=chop($impf); echo "<p align=CENTER> <input type=button value='$valor' onclick=location.href='factrad.php'></p>"; echo "<table align='left' width='225' cellspacing='2' cellpadding='2'border='1'>"; echo "<tr>"; echo "<td readonly=readlonly><b>ID</td>"; echo "<td readonly=readlonly><b>CLAVE USUARIO</td>"; echo "<td readonly=readlonly><b>SIGLAS</td>"; echo "<td readonly=readlonly><b>RAZON SOCIAL</td>"; echo "</tr>"; while($row=mysql_fetch_array($res)) { $id[]=$row["id"]; $cve[] = $row ["cveusuario"]; $sigla[] = $row ["siglasradio"]; $razon[] = $row ["razonsoc"]; /* echo "<tr>"; echo "<td><input type=text name='' size='15' style='text-align:center' maxlenght='100' readonly='readonly' value='$row[id]'></td>"; echo "<td><input type=text name='' size='15' style='text-align:center' maxlenght='100' readonly='readonly' value='$row[cveusuario]'></td>"; echo "<td><input type=text name='' size='15' style='text-align:center' maxlenght='100' readonly='readonly' value='$row[siglasradio]'></td>"; echo "<td><input type=text name='' size='65' style='text-align:center' maxlenght='100' readonly='readonly' value='$row[razonsoc]'></td>"; echo "<td><input type=text name='num' size='15' style='text-align:center' maxlenght='100' ></td>"; echo "</tr>"; */ } echo "<tr>"; echo "<td><input type=text size=1 readonly='readonly'></td>"; echo "</tr>"; $t = count($id); for ($i = 0; $i < $t; $i++) { echo "<tr>"; echo "<td><input type=text name='clave' size='15' style='text-align:center' maxlenght='100' readonly='readonly' value='$id[$i]'></td>"; echo "<td><input type=text name='clave' size='15' style='text-align:center' maxlenght='100' readonly='readonly' value='$cve[$i]'></td>"; echo "<td><input type=text name='sigg' size='15' style='text-align:center' maxlenght='100' readonly='readonly' value='$sigla[$i]'></td>"; echo "<td><input type=text name='razz' size='65' style='text-align:center' maxlenght='100' readonly='readonly' value='$razon[$i]'></td>"; } echo "</tr>"; echo "</table>"; echo "<table width='225' cellspacing='2' cellpadding='2' border=1>"; echo "<tr><td readonly=readlonly><b>NUMERAR </td></tr>"; echo "<tr><td><input type=text name='num' size='10' style='text-align:center' maxlenght='100' value=''><input type=submit value='numerar'></td></tr>"; for($b=0; $b<$t; $b++) { $c=$num++; echo "<tr><td><input type=text size='15' name='numera' style='text-align:center' maxlenght='100' readonly=readonly value=$c></td></tr>"; // echo $c; echo $b; $zz[]=$c; // query para actualizar la bd y agregar el numero de factura a los registros que aun no lo tienen en base a la consulta previa // $insertar="update factrad set numfact=$numera where estatus='orden'"; // mysql_query($insertar, $conn); } $zm=count($zz); for($d=0; $d<$t; $d++) { echo $zz[$d]; // query para actualizar la bd y agregar el numero de factura a los registros que aun no lo tienen en base a la consulta previa $insertar=mysql_query("update factrad set numfact=$zz[$d] where $id[$d] AND estatus='orden'"); } echo "</table>"; echo "</form>"; echo "</pre>"; echo "</html>"; } ?>