tengo un problema con un sistema que estoy haciendo tengo el siguiente php y donde tiene diferentes condiciones pero no logro resolver como hacer para que me haga un UPDATE despues de el INSERT, el problema es que quiero que consulte en la base de datos el numero de reportes que se han realizado y si es igual a la cantidad que pide la orden se ponga en estatus complete
Código PHP:
<?php
$conx = @mysql_connect("localhost","root","");
if (!$conx)
{
die('could not connect: ' . mysql_error());
}
{
$schedule = $_POST['schedule'];
$go = $_POST['go'];
$estilo = $_POST['estilo'];
$serie = $_POST['serie'];
$status = $_POST['statusemp'];
$id = $_POST['id'];
}
mysql_select_db("eaton", $conx);
$consulta= "SELECT info.schedule,info.general_order,info.style_number,empaque.idtxemp,final.idtxfinal,empaque.statusemp,empaque.statusemp,info.item_quantity_open
from info LEFT JOIN final ON info.schedule = final.schedule
LEFT JOIN empaque ON final.schedule = empaque.schedule
WHERE info.schedule='$schedule'";
$resuta= mysql_query($consulta) or die(mysql_error());
$raw =mysql_fetch_array($resuta);
$consul= "SELECT * FROM empaque WHERE schedule='$schedule'";
$ruw=mysql_query($consul) or die (mysql_error());
$numero=mysql_num_rows($ruw);
if($numero ==$raw['item_quantity_open']){
echo "<script language='javascript'>
alert('La orden esta completa.')
window.location='pruef.html'</script>";
}
elseif($id==$raw['idtxemp'] and $raw['statusemp']=="Complete"){echo "<script language='javascript'>
alert('Esta unidad ya esta reportada en Empaque.')
window.location='core.html'</script>";
}
elseif($id==$raw['idtxemp'] and $raw['statusemp']=="Rework"){
mysql_select_db("eaton", $conx);
$sql2="UPDATE empaque SET statusemp = '$status' WHERE idtxemp = '$id'";
if (!mysql_query($sql2,$conx));
{
//die('Error; ' . mysql_error());
}
mysql_close($conx);
}
elseif($raw['schedule']==$schedule and $raw['general_order']==$go and $raw['style_number']== $estilo and $raw['idtxfinal']==$id )
{
mysql_select_db("eaton", $conx);
$sql="INSERT INTO empaque (schedule,go,estilo,serie,idtxemp,statusemp,fechaemp)
VALUES ('$schedule','$go','$estilo','$serie','$id','$status',now())";
if (!mysql_query($sql,$conx));
mysql_select_db("eaton", $conx);
$sql="UPDATE final SET statusfinal = 'Complete' WHERE idtxfinal = '$id'";
if (!mysql_query($sql,$conx));
{
//die('Error; ' . mysql_error());
}
mysql_close($conx);
"<script language='javascript'>
window.location='status.php'</script>";
}
else{
echo
"<script language='javascript'>
alert('La unidad no esta reportada en Final.')
window.location='core.html'</script>";
}
?>
<script language="javascript">
window.location="final.html";
</script>
y lo que quiero hacer es que me si se cumple la condición del INSER me autodireccione a otro PHP y hacer el UPDATE que necesito