gini gan gmna caranya menyimpan data setelah dipilih pada combobox, jadi gini file combobox
  1.  
  2. <form action="" method="post">
  3. <select name="id_peserta">
  4. <option>-Pilih Hasil Undian-</option>
  5. <?php
  6. $host = "localhost";
  7. $user = "root";
  8. $pass = "";
  9. $db = "db_arisan";
  10. $connect = mysql_connect($host, $user, $pass);
  11. $sukses = mysql_select_db($db, $connect);
  12.  
  13. $tanggal = @$_POST['tanggal'];
  14. $nama_peserta = @$_POST['nama_peserta'];
  15. $alamat = @$_POST['alamat'];
  16. $no_hp = @$_POST['no_hp'];
  17. $jenis_kelamin = @$_POST['jenis_kelamin'];
  18.  
  19. $sql = mysql_query("SELECT * FROM tbl_peserta ORDER BY id_peserta ASC");
  20. if(mysql_num_rows($sql) != 0){
  21. while($data = mysql_fetch_assoc($sql)){
  22. echo '<option>'.$data['id_peserta'].'</option>';
  23. }
  24. }
  25. ?>
  26. <input type="submit" name="submit" value="OK" />
  27. </select>
  28. </form>
trus ini code menyimpan pada tabel setelah combobox dipilih dan tombol ok ditekan
  1. <?php
  2. $host = "localhost";
  3. $user = "root";
  4. $pass = "";
  5. $db = "db_arisan";
  6. $connect = mysql_connect($host, $user, $pass);
  7. $sukses = mysql_select_db($db, $connect);
  8.  
  9. $id_peserta = @$_POST['id_peserta'];
  10. $tanggal = @$_POST['tanggal'];
  11. $nama_peserta = @$_POST['nama_peserta'];
  12. $alamat = @$_POST['alamat'];
  13. $no_hp = @$_POST['no_hp'];
  14. $jenis_kelamin = @$_POST['jenis_kelamin'];
  15.  
  16. $pemenang =@$_POST['submit'];
  17.  
  18. if($pemenang) {
  19. 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());
  20. {
  21. ?>
  22. <script type="text/javascript">
  23. alert("PEMENANG ARISAN BULAN INI ADALAH...");
  24. window.location.href = "work03.php?page=record";
  25. </script>
  26. <?php
  27. }
  28. }
  29. ?>
dan ini tabel tempat nantinya data disimpan
  1. <table width="100%" border="1px" style="border-collapse:collapse;">
  2. <tr style="background-color:#33CCB7">
  3. <th style="text-align: center; color: #000000;">ID PESERTA</th>
  4. <th style="text-align: center; color: #000000;">TANGGAL DAFTAR</th>
  5. <th style="text-align: center; color: #000000;">NAMA</th>
  6. <th style="text-align: center; color: #000000;">ALAMAT</th>
  7. <th style="text-align: center; color: #000000;">TELEPON</th>
  8. <th style="text-align: center; color: #000000;">JENIS KELAMIN</th>
  9. <th style="text-align: center; color: #000000;">OPSI</th>
  10. </tr>
  11. <?php
  12. $host = "localhost";
  13. $user = "root";
  14. $pass = "";
  15. $db = "db_arisan";
  16. $connect = mysql_connect($host, $user, $pass);
  17. $sukses = mysql_select_db($db, $connect);
  18. $sql = mysql_query("select * from tbl_record") or die (mysql_error());
  19. while ($data = mysql_fetch_array($sql)) {
  20. ?>
  21. <tr>
  22. <td id="id_peserta" style="text-align: center"><?php echo $data['id_peserta']; ?></td>
  23. <td id="tanggal" style="text-align: left"><?php echo $data['tanggal']; ?></td>
  24. <td id= "nama_peserta" style="text-align: left"><?php echo $data['nama_peserta']; ?></td>
  25. <td id="alamat" style="text-align: left"><?php echo $data['alamat']; ?></td>
  26. <td id="no_hp" style="text-align: left"><?php echo $data['no_hp']; ?></td>
  27. <td id="jenis_kelamin" style="text-align: left"><?php echo $data['jenis_kelamin']; ?></td>
  28. <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 :(
1494
_FB_NAME_
0
  1. -- phpMyAdmin SQL Dump
  2. -- version 4.3.11
  3. -- http://www.phpmyadmin.net
  4. --
  5. -- Host: 127.0.0.1
  6. -- Generation Time: 15 Jan 2017 pada 14.07
  7. -- Versi Server: 5.6.24
  8. -- PHP Version: 5.5.24
  9.  
  10. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  11. SET time_zone = "+00:00";
  12.  
  13.  
  14. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  15. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  16. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  17. /*!40101 SET NAMES utf8 */;
  18.  
  19. --
  20. -- Database: `db_arisan`
  21. --
  22.  
  23. -- --------------------------------------------------------
  24.  
  25. --
  26. -- Struktur dari tabel `tbl_login`
  27. --
  28.  
  29. CREATE TABLE IF NOT EXISTS `tbl_login` (
  30. `id_admin` varchar(40) NOT NULL,
  31. `username` varchar(40) NOT NULL,
  32. `password` varchar(40) NOT NULL,
  33. `nama_lengkap` varchar(40) NOT NULL
  34. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  35.  
  36. --
  37. -- Dumping data untuk tabel `tbl_login`
  38. --
  39.  
  40. INSERT INTO `tbl_login` (`id_admin`, `username`, `password`, `nama_lengkap`) VALUES
  41. ('14210003', 'ogk', 'e00cf25ad42683b3df678c61f42c6bda', 'Ahmad Syauqi'),
  42. ('14210011', 'emma', 'c84258e9c39059a89ab77d846ddab909', 'Emma Putri Alivia');
  43.  
  44. -- --------------------------------------------------------
  45.  
  46. --
  47. -- Struktur dari tabel `tbl_peserta`
  48. --
  49.  
  50. CREATE TABLE IF NOT EXISTS `tbl_peserta` (
  51. `id_peserta` varchar(40) NOT NULL,
  52. `tanggal` date NOT NULL,
  53. `nama_peserta` varchar(40) NOT NULL,
  54. `alamat` varchar(40) NOT NULL,
  55. `no_hp` varchar(40) NOT NULL,
  56. `jenis_kelamin` varchar(40) NOT NULL,
  57. `inves` int(40) NOT NULL,
  58. `saldo` int(40) NOT NULL
  59. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  60.  
  61. --
  62. -- Dumping data untuk tabel `tbl_peserta`
  63. --
  64.  
  65. INSERT INTO `tbl_peserta` (`id_peserta`, `tanggal`, `nama_peserta`, `alamat`, `no_hp`, `jenis_kelamin`, `inves`, `saldo`) VALUES
  66. ('AY0001', '2017-01-01', 'jonkey', 'denpasar', '08756676211', 'Laki-laki', 50000, 50000),
  67. ('AY0002', '2017-01-01', 'taufiq', 'jalak putih', '08776233456', 'Laki-laki', 50000, 100000),
  68. ('AY0003', '0000-00-00', 'razzan', 'jalan cempaka', '0987764634', 'Laki-laki', 50000, 0);
  69.  
  70. -- --------------------------------------------------------
  71.  
  72. --
  73. -- Struktur dari tabel `tbl_record`
  74. --
  75.  
  76. CREATE TABLE IF NOT EXISTS `tbl_record` (
  77. `id_peserta` varchar(40) NOT NULL,
  78. `tanggal` date NOT NULL,
  79. `nama_peserta` varchar(40) NOT NULL,
  80. `alamat` varchar(40) NOT NULL,
  81. `no_hp` varchar(40) NOT NULL,
  82. `jenis_kelamin` varchar(40) NOT NULL
  83. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  84.  
  85. --
  86. -- Indexes for dumped tables
  87. --
  88.  
  89. --
  90. -- Indexes for table `tbl_login`
  91. --
  92. ALTER TABLE `tbl_login`
  93. ADD PRIMARY KEY (`id_admin`);
  94.  
  95. --
  96. -- Indexes for table `tbl_peserta`
  97. --
  98. ALTER TABLE `tbl_peserta`
  99. ADD PRIMARY KEY (`id_peserta`);
  100.  
  101. --
  102. -- Indexes for table `tbl_record`
  103. --
  104. ALTER TABLE `tbl_record`
  105. ADD PRIMARY KEY (`id_peserta`);
  106.  
  107. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  108. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  109. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  110.  
db_arisan ini database
  • Jan 15, 2017
  • 0 suka, 0 tidak suka
4961
Please login to answer!
/sangkep/answer/add-json/nogzip/1
/sangkep/answer/send-notification
User Paling Aktif Bulan Lalu

Asrianor

Point Bulan Lalu: 6