我在下面收到这些错误:
Notice: Undefined offset: 1 in ... on line 93
Notice: Undefined offset: 2 in ... on line 94
这些错误是什么意思,如何解决?我看不出问题出在哪里,但我知道在单击“模块提交”按钮后它们会出现
$模块活动 = 1;
$sql = "SELECT ModuleId, ModuleNo, ModuleName FROM Module WHERE ModuleActive = ? ORDER BY ModuleNo";
$sqlstmt=$mysqli->prepare($sql);
$sqlstmt->bind_param("i", $moduleactive);
$sqlstmt->execute();
$sqlstmt->bind_result($dbModuleId,$dbModuleNo,$dbModuleName);
$moduleHTML = "";
$moduleHTML .= '<select name="modules" id="modulesDrop">'.PHP_EOL;
$moduleHTML .= '<option value="">Please Select</option>'.PHP_EOL;
while($sqlstmt->fetch()) {
$moduleHTML .= sprintf('<option value="%1$s_%2$s_%3$s">%1$s - %2$s</option>'.PHP_EOL, $dbModuleNo, $dbModuleName, $dbModuleId);
}
$moduleHTML .= '</select>';
$pHTML = "";
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return validation(event);">
<table>
<tr>
<th>Module: <?php echo $moduleHTML; ?></th>
</tr>
</table>
<p><input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit" /></p>
<div id="moduleAlert"></div>
<div id="targetdiv"></div>
</form>
<?php
if (isset($_POST['moduleSubmit'])) {
$outputmodule = "";
$moduleInfo = explode("_", $_POST['modules']);
$moduleNo = $moduleInfo[0];
$moduleName = $moduleInfo[1]; //Error line 93
$moduleId = $moduleInfo[2]; //Error line 94
$outputmodule = sprintf("<p><strong>Selected Module:</strong> %s - %s <input type='hidden' value='%s'></p>", $moduleNo, $moduleName, $moduleId);
}
?>