memanggil data dengan combobox

Ogk Achmad · Jan 15, 2017
gini gan gmna caranya menyimpan data setelah dipilih pada combobox, jadi gini file combobox

	<form action="" method="post">
	<select name="id_peserta">
    <option>-Pilih Hasil Undian-</option>
<?php
$host 		= "localhost";
$user 		= "root";
$pass 		= "";
$db 		= "db_arisan";
$connect	= mysql_connect($host, $user, $pass);
$sukses		= mysql_select_db($db, $connect);

$tanggal 		= @$_POST['tanggal'];
$nama_peserta	= @$_POST['nama_peserta'];
$alamat			= @$_POST['alamat'];
$no_hp			= @$_POST['no_hp'];
$jenis_kelamin	= @$_POST['jenis_kelamin'];

$sql 			= mysql_query("SELECT * FROM tbl_peserta ORDER BY id_peserta ASC");
if(mysql_num_rows($sql) != 0){
	while($data = mysql_fetch_assoc($sql)){
		echo '<option>'.$data['id_peserta'].'</option>';
	}
}
?>
<input type="submit" name="submit" value="OK" />
	</select>
	</form>
trus ini code menyimpan pada tabel setelah combobox dipilih dan tombol ok ditekan
<?php
$host	 = "localhost";
$user    = "root";
$pass 	 = "";
$db  	 = "db_arisan";
$connect = mysql_connect($host, $user, $pass);
$sukses  = mysql_select_db($db, $connect);

$id_peserta		= @$_POST['id_peserta'];
$tanggal		= @$_POST['tanggal'];
$nama_peserta	= @$_POST['nama_peserta'];
$alamat			= @$_POST['alamat'];
$no_hp			= @$_POST['no_hp'];
$jenis_kelamin	= @$_POST['jenis_kelamin'];

$pemenang 		=@$_POST['submit'];

	if($pemenang) {
		 mysql_query ("insert into tbl_record (id_peserta,tanggal,nama_peserta,alamat,no_hp,jenis_kelamin) values ('$id_peserta', '$tanggal', '$nama_peserta', '$alamat', '$no_hp', '$jenis_kelamin')") or die (mysql_error());
	{
?>
	<script type="text/javascript">
		alert("PEMENANG ARISAN BULAN INI ADALAH...");
		window.location.href = "work03.php?page=record";
	</script>
<?php
	}
	}
?>   
dan ini tabel tempat nantinya data disimpan
<table width="100%"  border="1px" style="border-collapse:collapse;">
    	<tr style="background-color:#33CCB7">
        	<th style="text-align: center; color: #000000;">ID PESERTA</th>
            <th style="text-align: center; color: #000000;">TANGGAL DAFTAR</th>
            <th style="text-align: center; color: #000000;">NAMA</th>
            <th style="text-align: center; color: #000000;">ALAMAT</th>
            <th style="text-align: center; color: #000000;">TELEPON</th>
            <th style="text-align: center; color: #000000;">JENIS KELAMIN</th>
            <th style="text-align: center; color: #000000;">OPSI</th>
       </tr>
<?php
$host		 = "localhost";
$user	   	 = "root";
$pass 		 = "";
$db 		 = "db_arisan";
$connect 	 = mysql_connect($host, $user, $pass);
$sukses 	 = mysql_select_db($db, $connect);
$sql 	 	 = mysql_query("select * from tbl_record") or die (mysql_error());
while ($data = mysql_fetch_array($sql)) {
?>
        <tr>
        	<td id="id_peserta" style="text-align: center"><?php echo $data['id_peserta']; ?></td>
            <td id="tanggal" style="text-align: left"><?php echo $data['tanggal']; ?></td>
            <td id= "nama_peserta" style="text-align: left"><?php echo $data['nama_peserta']; ?></td>
            <td id="alamat" style="text-align: left"><?php echo $data['alamat']; ?></td>
            <td id="no_hp" style="text-align: left"><?php echo $data['no_hp']; ?></td>
            <td id="jenis_kelamin" style="text-align: left"><?php echo $data['jenis_kelamin']; ?></td>
            <td>
gimana caranya ketika memilih salah satu combobox kemudian di tekan 'ok' maka value akan tersimpan pada tabel yg diambil dari nilai combobox
mohon bantuan secepatnya :(
Silahkan login untuk menjawab!
0
Loading...
Ogk Achmad · Jan 15, 2017 · 0 Suka · 0 Tidak Suka
-- phpMyAdmin SQL Dump
-- version 4.3.11
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: 15 Jan 2017 pada 14.07
-- Versi Server: 5.6.24
-- PHP Version: 5.5.24

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `db_arisan`
--

-- --------------------------------------------------------

--
-- Struktur dari tabel `tbl_login`
--

CREATE TABLE IF NOT EXISTS `tbl_login` (
  `id_admin` varchar(40) NOT NULL,
  `username` varchar(40) NOT NULL,
  `password` varchar(40) NOT NULL,
  `nama_lengkap` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data untuk tabel `tbl_login`
--

INSERT INTO `tbl_login` (`id_admin`, `username`, `password`, `nama_lengkap`) VALUES
('14210003', 'ogk', 'e00cf25ad42683b3df678c61f42c6bda', 'Ahmad Syauqi'),
('14210011', 'emma', 'c84258e9c39059a89ab77d846ddab909', 'Emma Putri Alivia');

-- --------------------------------------------------------

--
-- Struktur dari tabel `tbl_peserta`
--

CREATE TABLE IF NOT EXISTS `tbl_peserta` (
  `id_peserta` varchar(40) NOT NULL,
  `tanggal` date NOT NULL,
  `nama_peserta` varchar(40) NOT NULL,
  `alamat` varchar(40) NOT NULL,
  `no_hp` varchar(40) NOT NULL,
  `jenis_kelamin` varchar(40) NOT NULL,
  `inves` int(40) NOT NULL,
  `saldo` int(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data untuk tabel `tbl_peserta`
--

INSERT INTO `tbl_peserta` (`id_peserta`, `tanggal`, `nama_peserta`, `alamat`, `no_hp`, `jenis_kelamin`, `inves`, `saldo`) VALUES
('AY0001', '2017-01-01', 'jonkey', 'denpasar', '08756676211', 'Laki-laki', 50000, 50000),
('AY0002', '2017-01-01', 'taufiq', 'jalak putih', '08776233456', 'Laki-laki', 50000, 100000),
('AY0003', '0000-00-00', 'razzan', 'jalan cempaka', '0987764634', 'Laki-laki', 50000, 0);

-- --------------------------------------------------------

--
-- Struktur dari tabel `tbl_record`
--

CREATE TABLE IF NOT EXISTS `tbl_record` (
  `id_peserta` varchar(40) NOT NULL,
  `tanggal` date NOT NULL,
  `nama_peserta` varchar(40) NOT NULL,
  `alamat` varchar(40) NOT NULL,
  `no_hp` varchar(40) NOT NULL,
  `jenis_kelamin` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbl_login`
--
ALTER TABLE `tbl_login`
  ADD PRIMARY KEY (`id_admin`);

--
-- Indexes for table `tbl_peserta`
--
ALTER TABLE `tbl_peserta`
  ADD PRIMARY KEY (`id_peserta`);

--
-- Indexes for table `tbl_record`
--
ALTER TABLE `tbl_record`
  ADD PRIMARY KEY (`id_peserta`);

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
db_arisan ini database