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