我正在尝试通过php更新mysql表行。 我正在使用joomla 3作为系统基础。 我正在做的是:
PHP页面,其中显示了特定用户组的列表:
$groupId = 10;
$access = new JAccess();
$members = $access->getUsersByGroup($groupId);
$rows = '<table id="hreilist"><tr>
<th class="tblth2">ID</th>
<th class="tblth3">Name</th>
<th class="tblth4">Username</th>
<th class="tblth5">E-Mail</th>
<th class="tblth6">Status</th>
<th> </th>
</tr>';
foreach ($members as $id){
$user = JFactory::getUser($id);
$rows .= '<tr>';
$rows .= '<td class="tblusers">' . $user->id . '</td>';
$rows .= '<td class="tblusers">' . $user->name . '</td>';
$rows .= '<td class="tblusers">' . $user->username . '</td>';
$rows .= '<td class="tblusers">' . $user->email . '</td>';
$rows .= '<td class="tblusers tblactive">' . $user->block . '</td>';
$rows .= '<td class="tblusers tbldelete"><a href="modifiche/disableUser.php?id=' . $user->id . '">Delete</a></td>';
$rows .= '</tr>';
}
$rows .= '</table>';
echo $rows;
另一个PHP(disableUser.php),应在“删除”时更新“用户”表行,点击
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$object = new stdClass();
$object->id = $_GET["id"];
$result = JFactory::getDbo()->updateObject('#__users', $object, 'id');