Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/05/2008, 19:23
raab
 
Fecha de Ingreso: mayo-2008
Ubicación: Guadalajara
Mensajes: 28
Antigüedad: 15 años, 11 meses
Puntos: 0
Exclamación como sacar el numero maximo de un campo

Hola amigos me podrian ayudar me da el siguiente error a la hora de querer insertar una compra (enviar el formulario) ahi marque la fila del error es al guardar el numero max de cod_compra

Parse error: syntax error, unexpected '}' in C:\AppServ\www\sistema\RegCompra.php on line 55


//COMPRAS.PHP

<CENTER> <H1><FONT SIZE =+7 COLOR = "#000000">COMPRAS</FONT></H1> </CENTER>


<form action="RegCompra.php" method="POST">
<BR><BR>
<FONT SIZE = +2 COLOR = "#000000"> REGISTRO DE COMPRA <B></B></FONT>
<BR><BR><BR>

<?php
$conexion= mysql_connect('127.0.0.1','root','root');
mysql_select_db('papeleria',$conexion);



?>

<FONT COLOR="#000000" Size = 5>Articulo: </FONT><br /><input type="text" name="articulo" /><br /><br />

<FONT COLOR="#000000" Size = 5>Precio de Compra: </FONT><br /><input type="text" name="PrecioCom" /><br /><br />

<FONT COLOR="#000000" Size = 5>Precio de Venta: </FONT><br /><input type="text" name="PrecioVent" /><br /><br />

<FONT COLOR="#000000" Size = 5>Numero de Articulos: </FONT><br /><input type="text" name="numArtComp" /><br /><br />


<table border="1" cellpadding="0" cellspacing="0">

<tr>
<th colspan="2" width="300">Forma de Pago</th>
</tr>
<tr>
<td width="150"></td>
<td width="150">
<select name="tipoPago">
<option value="">Selecciona una opcion</option>
<option value="Efectivo">Efectivo</option>
<option value="Tarjeta">Tarjeta</option>;

</select>

</td>
</tr>
</table>

<br /><br />

<table border="1" cellpadding="0" cellspacing="0">

<tr>
<th colspan="2" width="300">Proveedores</th>
</tr>
<tr>
<td width="150">Proveedor</td>
<td width="150">
<select name="proveedor">
<option value="">Selecciona el proveedor</option>
<?php
$query="SELECT cod_prov,nom_proveedor FROM proveedores";
$con=mysql_query($query,$conexion);
while($art=mysql_fetch_array($con)){
echo "<option value='$art[cod_prov]'>$art[nom_proveedor]</option>";
}
?>
</select>

</td>
</tr>
</table>
<br /><br />


<input type="submit" value="Enviar" />
<input type="reset" value="Limpiar" /><br />
</p>
</form>

//RegCompra.php

<?php

$conexion= mysql_connect('127.0.0.1','root','root');
mysql_select_db('papeleria',$conexion);

$art=$_POST['articulo'];
$precioCom=$_POST['precioCom'];
$precioVent=$_POST['precioVent'];
$numArtComp=$_POST['numArtComp'];
$tipoPago=$_POST['tipoPago'];

$con=mysql_query("SELECT cod_articulo,num_art_ex FROM articulos WHERE nom_articulo=$art",$conexion);
$utilidad=$precioVent-$precioCom;

if(!$con){
$query="INSER INTO articulos (nom_articulo, precio_compra, precio_venta, num_art_ex, utilidad) VALUES('$art','$precioCom','$precioVent',$numArtCo mp,$utilidad)";
$cons=mysql_query($query,$conexion) or die(mysql);

}else{
$artEx=$com+$numArtComp;
$query="UPDATE articulos SET num_art_ex=$artEx, precio_compra=$precioCom, precio_venta=$precioVent, utilidad=$utilidad WHERE nom_articulo=$art";
$cons=mysql_query($query,$conexion) or die(mysql);
}

$total=$numArtComp*$precioVent;

$query="INSER INTO compras (cod_articulo, cod_prov, forma_pago_c, num_art_comp, total_compra) VALUES('$art','$codProv','$tipoPago','$numArtComp' ,'$total')";
$con=mysql_query($query,$conexion) or die(mysql);

?>


<table border="1" cellpadding="0" cellspacing="0">

<tr>
<th colspan="5" width="300">Compra</th>
</tr>
<tr>
<th width="150">Cod Compra</th>
<th width="150">Cod de Articulo</th>
<th width="150">Cod Proveedor</th>
<th width="150">Forma de Pago</th>
<th width="150">Num de Articulos</th>
<th width="150">Total</th>

</tr>

<?php
$query="SELECT MAX(cod_compra) maximo FROM compras";
$resultado=mysql_query($query,$conexion);
while ( $fila=mysql_fetch_array($resultado) )
{
$max=$fila["maximo"]
} //Error:fila 55
$query="SELECT cod_compra, cod_articulo, cod_prov, forma_pago_c, num_art_comp, total_compra FROM compras WHERE cod_compra=$max";
$com=mysql_query($query,$conexion);

while($art=mysql_fetch_array($com)){ ?>
<tr>
<th width="150"><?php echo $art["cod_compra"]?></th>
<th width="150"><?php echo $art["cod_articulo"]?></th>
<th width="150"><?php echo $art["cod_prov"]?></th>
<th width="150"><?php echo $art["forma_pago_c"]?></th>
<th width="150"><?php echo $art["num_art_comp"]?></th>
<th width="150"><?php echo $art["total_compra"]?></th>
</tr>
<?php
}
?>

<BR><BR>

</table>

<A HREF="Compras.html" TARGET="PRINCIPAL"><h4>Regresar a Compras</h4></A></TD>
</TR>