フィールドとドロップダウンリストを持つフォームがあります。ドロップダウンリストのデータは、表categorieから出力されます。ドロップダウンリストのIDを他のテーブルに保存
ドロップダウンリストからカテゴリを選択し、他のすべての入力フィールドを入力すると、すべての入力フィールドが格納され、カテゴリテーブルのcatNameのみがtabel:イベントに保存されます(フィールドはcatID、catName)。 categorieテーブルの選択したcatIDもイベントテーブルに保存するにはどうすればよいですか?
誰かが私をここに案内できますか?あなたが選択した子からのテイク値をしたい場合は、<option id="id"></option>
でミスを犯した
よろしく、ベニー
<?php require '../Connections/localhost.php'; ?>
<?php
if(isset($_POST['newEvent'])) {
session_start();
$eventName = $_POST['SelCatName'];
$eventSDate = $_POST['Event-StartDate'];
$eventSTime = $_POST['Event-StartTime'];
$eventEDate = $_POST['Event-EndDate'];
$eventETime = $_POST['Event-EndTime'];
$eventDescription = $_POST['Event-Description'];
$catID = $_POST["catID"];
$sql = $con->query("INSERT INTO event (eventName, eventSDate, eventSTime, eventEDate, eventETime, eventDescription, catID)Values('{$eventName}', '{$eventSDate}', '{$eventSTime}', '{$eventEDate}', '{$eventETime}', '{$eventDescription}', '{$catID}')");
header('Location: eventOK.php');
}
?>
<form action="" method="post" name="RegisterForm" id="RegisterForm">
<div class="FormElement">
<select name="SelCatName" class="TField" id="SelCatName">
<option selected="selected" id="0">--Selecteer een categorie--</option>
<?php
$GetAllCategories = $con->query("SELECT * FROM categorie");
while ($ViewAllCategories = mysqli_fetch_array($GetAllCategories)){
?>
<option id="<?php echo $ViewAllCategories['catID']; ?>"><?php echo $ViewAllCategories ['catName']; ?> </option>
<?php } ?>
</select>
ありがとうございます。 ここで、catIDのみがテーブル・イベントに格納されます。 また、catNameは、eventNameフィールド以外のイベントテーブルに格納される必要があります。 – Benny
私のアンサーを更新してください。 1つのオプションから2つの値を取得するためにexplodeを使用します... –
catIDまたはcatNameはテーブルに格納されません。 – Benny