我想将所选“选择表单”的值插入到我的mysql数据库中 这个'select from'也连接到数据库
<label>Kategori</label>
<select class="form-control">
<?php include "config.php";
$kat = mysql_query("select * from kategori order by kode_kategori");
while ($hasil = mysql_fetch_array($kat)){
echo "<option value = '$hasil[kode_kategori]'>$hasil[nama_kategori]</option>";
}
?>
</select>
答案 0 :(得分:0)
首先,学习SQL。学习基础知识
要插入某些内容,这里是语法
$sql = "INSERT INTO mytable ('username', 'password') VALUES ('$_POST[username]', '$_POST[password]');";
答案 1 :(得分:0)
您可以在数据库中插入值,如下面的代码:
<?php
if(isset($_POST['submit_button_name'])){
$insert_value = mysql_query("INSERT INTO mytable ('Column name1', 'Colum name2' , 'Column name3') VALUES ('$_POST['file_name1']', '$_POST['filed_name2']','$_POST['filed_name3']'");
if($insert_value){
echo "value insert successfully..."
}
else{
echo "error while insert data.."
}
}
?>