2
將數據發送給後陣列比較有效,我想尋求一些幫助使我的代碼要通過使用循環更有效。在進入代碼之前,讓我描述下面的場景。如何使用循環,以使PHP
我發展,用戶通過它連接到時隙,其中有40我想用循環,使代碼更有效以下3個部分的複選框進入它們的可用性會議調度應用。
第1
$id1 = $_POST ['id1'];
$id2 = $_POST ['id2'];
etc etc etc
$id40 = $_POST ['id40'];
SECTION2
if (isset ($_POST ['slot1'])) $slot1 = 1; else $slot1 = 0;
if (isset ($_POST ['slot2'])) $slot2 = 1; else $slot1 = 0;
etc etc etc
if (isset ($_POST ['slot40'])) $slot40 = 1; else $slot1 = 0;
第3節
$sql = "INSERT INTO individualavailability (slotID, uniNum, available) VALUES
('$id1', '$uniNum', '$slot1'),
('$id2', '$uniNum', '$slot2'),
etc etc etc
('$id40', '$uniNum', '$slot40')";
非常感謝斯特凡和Koredalin,您的幫助非常感謝....我會在今晚給您的建議一個嘗試! – Rodger123