私は、複数のレコード(ユーザー名)を表示し、それぞれに「チェックボックス」を持つフォームを持っています。ユーザーが[送信]ボタンをクリックすると、選択したレコードから情報を取得します。ここでは...私が持っているものである
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function jqCheckAll3(id, pID)
{
$("#" + pID + " :checkbox").attr('checked', $('#' + id).is(':checked'));
}
// End -->
</script>
<form name='myForm' action='adminprocess.php' method='POST'>
<table id='left' style='margin-bottom:5px;'>
<tr>
<th class='sortable'>Username</th><th class='sortable'>Name</th>
<th class='sortable'>Email</th><th class='sortable'>Level</th><th>Department</th><th class='sortable'>Registered</th><th>
<input type="checkbox" id="checkL" onclick="jqCheckAll3(this.id, 'left');"/></th>
</tr>
<?php
while($row = $result->fetch())
{
$regdate = $row['regdate'];
$reg = date("j M, y, g:i a", $regdate);
echo "<tr><td><a href='".$config['WEB_ROOT']."admin/index.php?id=6&usertoedit=".$username."'>".$username."</a></td>\n";
echo "<td>".$fname." ".$lname."</td>\n";
echo "<td>".$Uemail."</td>\n";
echo "<td>";
?>
<select name="ulevel" id="ulevel">
<option value="8">Supervisor</option>
<option value="6">Regular user</option>
<option value="5">Reports Only</option>
</select>
<?PHP
echo "</td>\n";
echo "<td>\n\t";
?>
<select name="departmentid" id="departmentid">
<option value="1">North East</option>
<option value="2">South</option>
<option value="3">Central</option>
</select>
<?PHP
echo "</td>\n";
echo "<td>".$reg."</td>\n";
echo "echo "</td>\n";
echo "<td>".$reg."</td>\n";
echo "</td><td><input name='user_name[]' type='checkbox' value='".$row['username']."' />";
echo "</td>\n</tr>";
echo "</td>\n</tr>";
}
?>
</table>
<input type="hidden" name="activateusers" value="1">
<input type="submit" value="Activate Selected Users">
<br>
</form>
と私のadminprocess.phpはこのようになります...
function procActivateUsers(){
global $session, $database, $mailer;
$config = $database->getConfigs();
/* Account edit attempt */
foreach($_POST['user_name'] as $username) {
$sql = $database->connection->prepare("UPDATE ".TBL_USERS." SET USERLEVEL = '".$_POST['ulevel']."', DEPTID = '".$_POST['departmentid']."' WHERE username = '$username'");
$sql->execute();
$req_user_info = $database->getUserInfo($username);
$email = $req_user_info['email'];
$mailer->adminActivated($username,$email,$config);
}
header("Location: ../admin/index.php?id=3");
}
は、私はすべてのことをやって、現時点では消毒または何か他のものを心配しないでください前。 > ulevel = 6 - - >のDepartmentID = 3、
ユーザー2 - > ulevel = 4 - >のDepartmentID = 1
任意の助け
をありがとうユーザー1:だけのようなものを取得する必要があり
私たちはここには見えないループが(HTML形式で)ありますか?そうでなければあなたの質問はあまり意味がないからです。 – Jeff
oops ...私のコピー&ペーストのスキルはそれほど良くはありません...私はループを表示するために質問を編集しました。 –
ループのたびに文を準備するべきではありません。ループの前に一度準備し、 'bindParam'を使用して変数にバインドし、ループ内で' execute() 'を呼び出します。 – Barmar