<?php
$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
mysql_selectDB("wauhaha_karaoke",$login);


$SupID = $_GET['SupID'];


$time=date('Y-m-d');

$c = $_POST['c'];
$PoID = $_POST['po'];
$TID =$_POST['TID'];
$result=mysql_query("select * from ksupplier where SupID='$SupID'");
$row = mysql_fetch_array($result);
$SupName = $row['SupName'];
for ($a=1; $a <$c; $a++)
{
$q=$_POST['q'.$a];
$pr=$_POST['pr'.$a];
$p=$_POST['p'.$a];
$tp=$_POST['t'.$a];
$query=mysql_query("INSERT INTO kporder(PoID,SupName,SupID,ProName,ProQuan,ProRQuan,price,total,Date)VALUE('$PoID','$SupName','$SupID','$p','$q','$q','$pr','$tp','$time')");
}
$query2=mysql_query("insert into kpo(po)value('$PoID')");

if(($query)&&($query2)){
	echo "<script language=javascript>alert('Add successful!!');window.location='http://www.wauhaha.com/karaoke/kitstock.php'</script>";
}
echo "<script language=javascript>alert('Add fail!!');window.location='http://www.wauhaha.com/karaoke/kitstock.php '</script>";
?>