我有下面的代码,我想问一下,如何根据之前的数据将源插入到其他表中的数据库中?我从数据库中获取数据并将其显示在复选框上,但是当我检查复选框并按下按钮 Tambah 时,数据被插入到表中,但数据错误,只有 0 和数组。<!DOCTYPE html><html><head> <title>kumpulan data command</title> <link rel="stylesheet" type="text/css" href="style.css"></head><body> <h1>Evaluation</h1> <h2>Data command</h2> <?php$db = new mysqli("localhost","root","","FWS_online");echo $db->connect_errno?'Koneksi gagal :'.$db->connect_error:'';$query = ("SELECT * FROM printer_function_commands") or die(mysql_error());$result = mysqli_query($db, $query);$pilihan = '';$data = array();if (isset($_POST['submit']) && isset($_POST['commands'])){ if (count($_POST['commands']) > 0) { $pilihan = serialize($_POST['commands']); echo "<p>Data berhasil disimpan ke database berupa ".$pilihan."</p>"; }}if ($pilihan <> ''){ $data = unserialize($pilihan);}?> <table border="1"> <tr> <th>ID</th> <th>No</th> <th>Commands</th> </tr> <?php include "database.php"; $data1 = mysql_query("select * from result_commands"); $no = 1; while($d = mysql_fetch_array($data1)){ ?> <tr> <td><?php echo $no++; ?></td> <td><?php echo $d['no_commands']; ?></td> <td><?php echo $d['commands']; ?></td> </tr> <?php } ?> </table> <br/> <h2>Input Banyak Data</h2> <form method="post" action="tambah.php"> <table border="1"> <tr> <th>ID</th> <th>No</th> <th>Commands</th> <th>Pilih</th> </tr> <?php include "database.php"; $data = mysql_query("select * from printer_function_commands"); $no = 1; while($d = mysql_fetch_array($data)){ ?>
1 回答
- 1 回答
- 0 关注
- 134 浏览
添加回答
举报
0/150
提交
取消