我試圖從插入HTML標籤中選擇一個值到MySQL:MySQL的:從選擇標記插入值成爲截斷
<select name="venuesend">
<option value="37">LATINO SPORTS CLUB</option>
<option value="38">RED HOOK VISION CENTER</option>
<option value="39">ANTHOLOGY FILM ARCHIVES</option>
<option value="40">HUMMINGBIRD STUDIOS</option>
<option value="41">THE PRODUCERS CLUB</option>
</select>
所以,如果選擇LATINO SPORTS CLUB
的37
的價值應該被髮送到MySQL 。但是,目前,發佈到MySQL的值始終是3
。所以,我猜這是因爲什麼原因被截斷的。
這是我的PHP和HTML表單:
<?php
//if "submit" is clicked
if(isset($_POST['upload2'])) {
//check if image files were uploaded
foreach($_FILES['images']['error'] as $err){
switch ($err){
case UPLOAD_ERR_NO_FILE:
echo 'No file sent.';
exit;
}
}
//iterate through each image file uploaded
for($x=0; $x<count($_FILES['images']['tmp_name']); $x++){
//THIS IS WHERE VENUESEND IS POSTED
$screeningID2 = $_POST['venuesend'][$x];
$file_name = $_FILES['images']['name'][$x];
$file_tmp = $_FILES['images']['tmp_name'][$x];
....
//SQL statement and Posting
$sql2 = "INSERT INTO screeningImages (screeningId, imageURL) VALUES ('$screeningID2', '$file_name')";
mysqli_query($db, $sql2);
} else{
echo "Only images can be stored.";
}
}
}
?>
//HTML Form
<form method="post" action="screenings-admin.php" enctype="multipart/form-data">
//SELECT
<select name="venuesend">
<option value="37">LATINO SPORTS CLUB</option>
<option value="38">RED HOOK VISION CENTER</option>
<option value="39">ANTHOLOGY FILM ARCHIVES</option>
<option value="40">HUMMINGBIRD STUDIOS</option>
<option value="41">THE PRODUCERS CLUB</option>
</select>
//Images Upload
<input type="file" id="imageUpload" name="images[]" multiple="" onchange="javascript:updateList()"/>
//submit button
<input type="submit" name="upload2" value="Upload" id="upload2">
</form>