shopping chart problem

admin

Administrator
Staff member
help me please, I cannot pick some items from the shopping chart, it only show the last item that I choose.
<?
$database="hilma";
$hostname="localhost";
$username="hilma76";
$passwd="123456";
$db=mysql_connect($hostname,$username,$passwd);
mysql_select_db($database,$db);

if('$kodebarang' != " " && $order== "Beli")
{
$order="select max(kodetransaksi) from detailtransaksisah";
if(!$result=mysql_query($order,$db))
{
echo mysql_error();
}
$row=mysql_fetch_row($result);
$kodetransaksi=$row[0];
$kodetransaksi++;
$tanggal=date('Y-m-d');
$addsql="insert into transaksisah(kodetransaksi,tanggal,userid) values('$kodetransaksi','$tanggal','$userid')";
if(!$result=mysql_query($addsql,$db))
{
echo mysql_error();
exit();
}
setcookie("kodetransaksi",$kodetransaksi);

$addsql="insert into detailtransaksisah(kodetransaksi,kodebarang,quantity) values('$kodetransaksi','$kodebarang',$quantity)";
if(!mysql_query($addsql,$db))
{
echo mysql_error();
}
}
else if ($order=="cancel")
{
$deletesql="delete from transaksisah where kodetransaksi='$kodetransaksi'";
mysql_query($deletesql,$db);

$deletesql="delete from detailtransaksisah where kodetransaksi='$kodetransaksi'";
mysql_query($deletesql,$db);
setcookie("kodetransaksi");
}

echo"<body bgcolor=#C8D3F8>";
echo"<h2>Barang yang dibeli</h2>";

if($kodetransaksi != "")
{
$sqlbeli="select barang.kodebarang,barang.nama_barang,(barang.harga * detailtransaksisah.quantity),barang.harga,detailtransaksisah.quantity,detailtransaksisah.kodetransaksi from detailtransaksisah,barang where detailtransaksisah.kodebarang=barang.kodebarang and detailtransaksisah.kodetransaksi='$kodetransaksi'";
if(! $result=mysql_query($sqlbeli,$db))
{
echo mysql_error();
}
echo "<table width=600 border=0>";
while($row=mysql_fetch_row($result))
{
echo "<tr>";
echo "<td width=200>Nama Barang:</td>";
echo "<td width=400>".$row[1]."</td></tr><tr>";
echo "<td width=200>Harga Barang</td>";
echo "<td width=100>".$row[3]."</td></tr><tr>";
echo "<td width=200>Quantity</td>";
echo "<td width=100>".$row[4]."</td></tr><tr>";
echo "<td width=200>Jumlah</td>";
echo "<td width=100>".$row[2]."</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";

$sqlbeli="select sum(barang.harga * detailtransaksisah.quantity) from detailtransaksisah,barang where detailtransaksisah.kodebarang=barang.kodebarang and detailtransaksisah.kodetransaksi='$kodetransaksi'";
if(! $result=mysql_query($sqlbeli,$db))
{
echo mysql_error();
exit();
}
$row=mysql_fetch_row($result);
echo ("Total belanja : $row[0]<br>\n");
echo "<p>";
echo "<a href='http://www.phpbuilder.com/board/archive/index.php/bayar1.php'>Pembayaran</a><br>";
echo "<a href='http://www.phpbuilder.com/board/archive/index.php/index4.php?order='cancel'>Batalkan Pembelian</a><br>";
echo "<a href='http://www.phpbuilder.com/board/archive/index.php/index1.php'>Lanjutkan Belanja</a>";
}
else
{
echo "<center><h3>Tidak Ada Belanja</h3></center>\n";
}
?>
 
Back
Top