如何从表中选择行,然后在 php mysql 中输入新表循环以进行计数选择,
以防万一图表。
在 localhost 中,此代码可以找到。但是当我尝试上网时,为什么 WHERE 子句中的第一条记录可以插入到 Orders 表中并像一样删除。
$sid = session_id();
$sql = mysql_query("SELECT * FROM cart WHERE id_session='$sid'");
// get orders number
$id_orders=mysql_insert_id();
while ($r=mysql_fetch_array($sql)) {
$item = $r['item'];
$size = $r['size'];
$kateg_bahan = $r['kateg_bahan'];
$warna = $r['warna'];
$jumlah = $r['jumlah'];
$harga = $r['harga'];
$sub_total = $r['sub_total'];
$id_keranjang =$r['id_keranjang'];
mysql_query("INSERT INTO orders(id_orders, id_kustomer, nama_kustomer, alamat, telpon, email, tgl_order, jam_order, jasa, id_kota, item, size, kateg_bahan, warna, jumlah, harga, sub_total)
VALUES('$id_orders', '$id_kustomer', '$nama','$alamat','$telpon','$email','$tgl_skrg','$jam_skrg', '$jasa', '$id_kota','$item', '$size', '$kateg_bahan', '$warna', '$jumlah', '$harga', '$sub_total')");
}
$delsql = mysql_query("SELECT * FROM keranjang WHERE id_session='$sid'");
while ($r=mysql_fetch_array($delsql)) {
mysql_query("DELETE FROM keranjang WHERE id_keranjang = '$r[id_keranjang]'");
}