嗨,大家好,我需要關於php的一些典型信息。我正在創建一個有多個選項的選擇框。我有6個圖像,那麼我需要當用戶選擇1,2,3和提交然後image1,image2,image3必須顯示在頁面上,當用戶選擇2,4,6和提交然後image2,image4,image6必須顯示所以我在PHP做什麼來獲得這個代碼我trid這麼多buut沒有運氣幫助我出來謝謝。用戶提交時用selectbox獲取圖像
<form method="get">
<select name="images" multiple="multiple">
<option name="img" value="image">1</option>
<option name="img" value="image">2</option>
<option name="img" value="image">3</option>
<option name="img" value="image">4</option>
<option name="img" value="image">5</option>
<option name="img" value="image">6</option>
</select>
<input type="submit" value="submit" name="submit">
</form>
這裏是php
<?php
//path to directory to scan. i have included a wildcard for a subdirectory
$directory = "images/*/";
//get all image files with a .jpg extension.
$images = glob("" . $directory . "*.jpg");
$imgs = '';
// create array
foreach($images as $image){ $imgs[] = "$image"; }
//shuffle array
shuffle($imgs);
//select first 20 images in randomized array
$imgs = array_slice($imgs, 0, 20);
//display images
foreach ($imgs as $img) {
echo "<img src='$img' /> ";
}
?>
,但我想這方面的工作提出感謝
所有選項的值都是相同的'image'。這將發送到服務器,那麼您將如何檢測用戶選擇的內容? – Pevara