membergroup | cantitle
Administrator | 1
And if they're not checked, they'd say 0 in the cantitle column...I just can't figure this out. The closest I got was actually getting it to put the value into there, but if you then unchecked it it wouldn't pass the 0 value, it would just skip the loop and not change the 1 value...I'd appreciate some help, I'm really lost. Here's what I've done:
Code: Select all
$request = mysql_query("SELECT * FROM `{$db_prefix}membergroups` WHERE ID_GROUP=1 OR ID_GROUP=8;") or database_error(__FILE__, __LINE__);
while ($row = mysql_fetch_array($request))
{
echo '
<tr>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"></td>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"><font size="2">' . $row['membergroup'] . '</font></td>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"><input type="checkbox" name="chk~[' . $row['ID_GROUP'] . ']" value=". $row['cantitle'] . '/></td>
</tr>';
}
$request = mysql_query("SELECT * FROM `{$db_prefix}membergroups` WHERE `grouptype`=0 AND ID_GROUP>2 AND ID_GROUP!=8;") or database_error(__FILE__, __LINE__);
while ($row = mysql_fetch_array($request))
{
echo '
<tr>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"></td>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"><font size="2">' . $row['membergroup'] . '</font></td>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"><input type="checkbox" name="chk~[' . $row['ID_GROUP'] . ']" value="'. $row['cantitle'] . '/></td>
</tr>';
}
echo '
<tr>
<td class="titlebg" bgcolor="' . $color['titlebg'] . '" colspan="3">
<a href="javascript:reqWin(''' . $scripturl . '?action=helpadmin;help=addctitle'')" class="help"><img src="' . $imagesdir . '/helptopics.gif" border="0" alt="' . $txt[119] . '" /></a>
<font size="2" class="text1" color="' . $color['titletext'] . '"><b>' . $txt['memtitle2'] . '</b></font>
</td>
</tr>';
$request = mysql_query("SELECT * FROM `{$db_prefix}membergroups` WHERE `grouptype`=1;") or database_error(__FILE__, __LINE__);
while ($row = mysql_fetch_array($request))
{
echo '
<tr>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"></td>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"><font size="2">' . $row['membergroup'] . '</font></td>
<td class="windowbg2" bgcolor="' . $color['windowbg2'] . '"><input type="checkbox" name="chk~[' . $row['ID_GROUP'] . ']" value="'. $row['cantitle'] . '/></td>
</tr>';
}Code: Select all
reset($_POST);
while(list($key, $val) = each($_POST)) {
if(substr($key, 0, 3) == "chk") {
$arKey = explode("~", $key);
$id = $arKey;
$request = mysql_query("UPDATE {$db_prefix}membergroups SET cantitle='$val' WHERE ID_GROUP='$id';") or database_error(__FILE__, __LINE__);
}
}Sincerely,
Methonis